Cache is a thread-safe fixed size LRU cache.
type Cache struct {
// contains filtered or unexported fields
}
func New(size int) *Cache
New creates an LRU of the given size.
func NewWithEvictionFunc(size int, f EvictionFunc) *Cache
NewWithEvictionFunc creates an LRU of the given size with the given eviction func.
func (c *Cache) Add(key Key, value interface{})
Add adds a value to the cache.
func (c *Cache) Clear()
Clear purges all stored items from the cache.
func (c *Cache) Get(key Key) (value interface{}, ok bool)
Get looks up a key's value from the cache.
func (c *Cache) Len() int
Len returns the number of items in the cache.
func (c *Cache) Remove(key Key)
Remove removes the provided key from the cache.
func (c *Cache) RemoveOldest()
RemoveOldest removes the oldest item from the cache.
type EvictionFunc = func(key Key, value interface{})
type Key = groupcache.Key