Documentation
¶
Index ¶
- type Cache
- func (c *Cache) Add(key, value interface{})
- func (c *Cache) AddWithDefaultExpires(key, value interface{})
- func (c *Cache) AddWithExpiresInSecs(key, value interface{}, expireAtSecs int64)
- func (c *Cache) Get(key interface{}) (value interface{}, ok bool)
- func (c *Cache) GetInvalidateClusterEvent() string
- func (c *Cache) GetOrAdd(key, value interface{}, ttl time.Duration) (actual interface{}, loaded bool)
- func (c *Cache) Keys() []interface{}
- func (c *Cache) Len() int
- func (c *Cache) Name() string
- func (c *Cache) Purge()
- func (c *Cache) Remove(key interface{})
- func (c *Cache) RemoveByPrefix(prefix string)
- type CacheProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a thread-safe fixed size LRU cache.
func NewWithParams ¶
func NewWithParams(size int, name string, defaultExpiry int64, invalidateClusterEvent string) *Cache
NewWithParams creates an LRU with the given parameters.
func (*Cache) Add ¶
func (c *Cache) Add(key, value interface{})
Add adds the given key and value to the store without an expiry.
func (*Cache) AddWithDefaultExpires ¶
func (c *Cache) AddWithDefaultExpires(key, value interface{})
AddWithDefaultExpires adds the given key and value to the store with the default expiry.
func (*Cache) AddWithExpiresInSecs ¶
AddWithExpiresInSecs adds the given key and value to the cache with the given expiry.
func (*Cache) Get ¶
Get returns the value stored in the cache for a key, or nil if no value is present. The ok result indicates whether value was found in the cache.
func (*Cache) GetInvalidateClusterEvent ¶
GetInvalidateClusterEvent returns the cluster event configured when this cache was created.
func (*Cache) GetOrAdd ¶
func (c *Cache) GetOrAdd(key, value interface{}, ttl time.Duration) (actual interface{}, loaded bool)
GetOrAdd returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. This API intentionally deviates from the Add-only variants above for simplicity. We should simplify the entire API in the future.
func (*Cache) Keys ¶
func (c *Cache) Keys() []interface{}
Keys returns a slice of the keys in the cache, from oldest to newest.
func (*Cache) RemoveByPrefix ¶
RemoveByPrefix deletes all keys containing the given prefix string.
type CacheProvider ¶
type CacheProvider struct{}
CacheProvider is an implementation of cache.Provider to create a new Lru Cache
func (*CacheProvider) Close ¶
func (c *CacheProvider) Close()
Close releases any resources used by the cache provider.
func (*CacheProvider) Connect ¶
func (c *CacheProvider) Connect()
Connect opens a new connection to the cache using specific provider parameters.
func (*CacheProvider) NewCache ¶
func (c *CacheProvider) NewCache(size int) cache.Cache
NewCache creates a new lru.Cache with given size.
func (*CacheProvider) NewCacheWithParams ¶
func (c *CacheProvider) NewCacheWithParams(size int, name string, defaultExpiry int64, invalidateClusterEvent string) cache.Cache
NewCacheWithParams creates a new lru.Cache with the given parameters.