Documentation ¶
Index ¶
- type Cache
- func (c *Cache) Add(key string, value interface{})
- func (c *Cache) AddWithDefaultExpires(key string, value interface{})
- func (c *Cache) AddWithExpiresInSecs(key string, value interface{}, expireAtSecs int64)
- func (c *Cache) Get(key string) (value interface{}, ok bool)
- func (c *Cache) GetInvalidateClusterEvent() string
- func (c *Cache) GetOrAdd(key string, value interface{}, ttl time.Duration) (actual interface{}, loaded bool)
- func (c *Cache) Keys() []string
- func (c *Cache) Len() int
- func (c *Cache) Name() string
- func (c *Cache) Purge()
- func (c *Cache) Remove(key 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) AddWithDefaultExpires ¶
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 string, 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.
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.