6 "github.com/golang/groupcache/lru"
9 // Cache is an LRU cache. It is safe for concurrent access.
15 // NewCache creates a new Cache.
16 // If maxEntries is zero, the cache has no limit and it's assumed
17 // that eviction is done by the caller.
18 func NewCache(maxEntries int) *Cache {
19 return &Cache{cache: lru.New(maxEntries)}
22 // Add adds a value to the cache.
23 func (c *Cache) Add(key, value interface{}) {
26 c.cache.Add(key, value)
29 // Get looks up a key's value from the cache.
30 func (c *Cache) Get(key interface{}) (value interface{}, ok bool) {
33 return c.cache.Get(key)
36 // Remove removes the provided key from the cache.
37 func (c *Cache) Remove(key interface{}) {
43 // RemoveOldest removes the oldest item from the cache.
44 func (c *Cache) RemoveOldest() {
47 c.cache.RemoveOldest()
50 // Len returns the number of items in the cache.
51 func (c *Cache) Len() int {
57 // Clear purges all stored items from the cache.
58 func (c *Cache) Clear() {