Documentation ¶
Overview ¶
This package provides a simple LRU cache. It is based on the LRU implementation in groupcache: https://github.com/golang/groupcache/tree/master/lru
This package provides a simple LRU cache. It is based on the LRU implementation in groupcache: https://github.com/golang/groupcache/tree/master/lru
Index ¶
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 (*Cache) Keys ¶
func (c *Cache) Keys() []interface{}
Keys returns a slice of the keys in the cache.
func (*Cache) Remove ¶
func (c *Cache) Remove(key interface{})
Remove removes the provided key from the cache.
func (*Cache) RemoveOldest ¶
func (c *Cache) RemoveOldest()
RemoveOldest removes the oldest item from the cache.
type FillingCache ¶
type FillingCache struct { Metrics ReportMetrics // contains filtered or unexported fields }
FillingCache is a LRU cache. It fills an entry the first time the entry is retrieved. It ensures the entry is filled once even when the entry is retrieved by multiple clients. An entry may expire. An expired entry goes through the filling process the same as a new entry. Note that if Fill fails, the error entry is cached.
func NewFillingCache ¶
func NewFillingCache(size int, fr Filler) *FillingCache
NewFillingCache returns a FillingCache of the given size.
func (*FillingCache) Get ¶
func (c *FillingCache) Get(key interface{}) (value interface{}, err error)
looks up a key's value from the cache, if it is not present get it