import "github.com/andy2046/gopie/pkg/lru"
Package lru implements a LRU cache.
type Cache struct {
// MaxEntries is the maximum number of cache entries
// before an item is purged. Zero means no limit.
MaxEntries int
// OnPurged specifies a function to be executed
// when an entry is purged from the cache.
OnPurged func(key interface{}, value interface{})
// contains filtered or unexported fields
}Cache is a LRU cache.
func New(maxEntries int) *CacheNew creates a new cache, if maxEntries is zero, the cache has no limit.
func (c *Cache) Add(key interface{}, value interface{})Add adds value to the cache.
func (c *Cache) Clear()Clear purges all items from the cache.
func (c *Cache) Get(key interface{}) (value interface{}, ok bool)Get looks up value by key from the cache.
func (c *Cache) Len() intLen returns the number of items in the cache.
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.
Generated by godoc2md