Documentation ¶
Index ¶
- Variables
- type Cache
- type CacheOptions
- type LRU
- func (l *LRU) Get(key string, value interface{}) error
- func (l *LRU) GetInvalidateClusterEvent() string
- func (l *LRU) Keys() ([]string, error)
- func (l *LRU) Len() (int, error)
- func (l *LRU) Name() string
- func (l *LRU) Purge() error
- func (l *LRU) Remove(key string) error
- func (l *LRU) Set(key string, value interface{}) error
- func (l *LRU) SetWithDefaultExpiry(key string, value interface{}) error
- func (l *LRU) SetWithExpiry(key string, value interface{}, ttl time.Duration) error
- type LRUOptions
- type Provider
Constants ¶
This section is empty.
Variables ¶
var ErrKeyNotFound = errors.New("key not found")
ErrKeyNotFound is the error when the given key is not found
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Purge is used to completely clear the cache. Purge() error // Set adds the given key and value to the store without an expiry. If the key already exists, // it will overwrite the previous value. Set(key string, value interface{}) error // SetWithDefaultExpiry adds the given key and value to the store with the default expiry. If // the key already exists, it will overwrite the previoous value SetWithDefaultExpiry(key string, value interface{}) error // SetWithExpiry adds the given key and value to the cache with the given expiry. If the key // already exists, it will overwrite the previoous value SetWithExpiry(key string, value interface{}, ttl time.Duration) error // Get the content stored in the cache for the given key, and decode it into the value interface. // Return ErrKeyNotFound if the key is missing from the cache Get(key string, value interface{}) error // Remove deletes the value for a given key. Remove(key string) error // Keys returns a slice of the keys in the cache. Keys() ([]string, error) // Len returns the number of items in the cache. Len() (int, error) // GetInvalidateClusterEvent returns the cluster event configured when this cache was created. GetInvalidateClusterEvent() string // Name returns the name of the cache Name() string }
Cache (under package cache2) is a representation of a cache store that aims to replace cache.Cache
type CacheOptions ¶ added in v5.26.0
type CacheOptions struct { Size int DefaultExpiry time.Duration Name string InvalidateClusterEvent string }
CacheOptions contains options for initializaing a cache
type LRU ¶
type LRU struct {
// contains filtered or unexported fields
}
LRU is a thread-safe fixed size LRU cache.
func (*LRU) Get ¶
Get the content stored in the cache for the given key, and decode it into the value interface. return ErrKeyNotFound if the key is missing from the cache
func (*LRU) GetInvalidateClusterEvent ¶
GetInvalidateClusterEvent returns the cluster event configured when this cache was created.
func (*LRU) Set ¶
Set adds the given key and value to the store without an expiry. If the key already exists, it will overwrite the previous value.
func (*LRU) SetWithDefaultExpiry ¶
SetWithDefaultExpiry adds the given key and value to the store with the default expiry. If the key already exists, it will overwrite the previoous value
type LRUOptions ¶
type LRUOptions struct { Name string Size int DefaultExpiry time.Duration InvalidateClusterEvent string }
LRUOptions contains options for initializing LRU cache
type Provider ¶ added in v5.26.0
type Provider interface { // NewCache creates a new cache with given options. NewCache(opts *CacheOptions) Cache // Connect opens a new connection to the cache using specific provider parameters. Connect() error // Close releases any resources used by the cache provider. Close() error }
Provider is a provider for Cache
func NewProvider ¶ added in v5.26.0
func NewProvider() Provider
NewProvider creates a new CacheProvider