Documentation ¶
Index ¶
Constants ¶
View Source
const (
TypeInMemoryCache = "InMemoryCache"
)
Variables ¶
View Source
var ErrNoSuchKey = errors.New("no such key")
View Source
var NeverExpire = time.Duration(0)
Functions ¶
func RegisterCacheFactory ¶
func RegisterCacheFactory(factory CacheFactory)
Types ¶
type CacheFactory ¶
type CacheFactory interface { // Type unique type of the cache Type() string // Create relevant caches by type Create(options options.DynamicOptions, stopCh <-chan struct{}) (Interface, error) }
type InMemoryCacheOptions ¶
type InMemoryCacheOptions struct {
CleanupPeriod time.Duration `json:"cleanupPeriod" yaml:"cleanupPeriod" mapstructure:"cleanupperiod"`
}
InMemoryCacheOptions used to create inMemoryCache in memory. CleanupPeriod specifies cleans up expired token every period. Note the SimpleCache cannot be used in multi-replicas apiserver, which will lead to data inconsistency.
type Interface ¶
type Interface interface { // Keys retrieves all keys match the given pattern Keys(pattern string) ([]string, error) // Get retrieves the value of the given key, return error if key doesn't exist Get(key string) (string, error) // Set sets the value and living duration of the given key, zero duration means never expire Set(key string, value string, duration time.Duration) error // Del deletes the given key, no error returned if the key doesn't exist Del(keys ...string) error // Exists checks the existence of a give key Exists(keys ...string) (bool, error) // Expire updates object's expiration time, return err if key doesn't exist Expire(key string, duration time.Duration) error }
func NewInMemoryCache ¶
func NewInMemoryCache(options *InMemoryCacheOptions, stopCh <-chan struct{}) (Interface, error)
func NewRedisClient ¶
type Options ¶
type Options struct { Type string `json:"type"` Options options.DynamicOptions `json:"options"` }
func NewCacheOptions ¶
func NewCacheOptions() *Options
NewCacheOptions returns options points to nowhere, because redis is not required for some components
Click to show internal directories.
Click to hide internal directories.