Documentation ¶
Index ¶
- type Cache
- func (c *Cache) Add(key, value interface{}, weight uint) (evicted int)
- func (c *Cache) Contains(key interface{}) (ok bool)
- func (c *Cache) Get(key interface{}) (value interface{}, ok bool)
- func (c *Cache) GetOldest() (key interface{}, value interface{}, ok bool)
- func (c *Cache) Keys() []interface{}
- func (c *Cache) Len() int
- func (c *Cache) Peek(key interface{}) (value interface{}, ok bool)
- func (c *Cache) Purge()
- func (c *Cache) Remove(key interface{}) (present bool)
- func (c *Cache) RemoveOldest() (key interface{}, value interface{}, ok bool)
- func (c *Cache) Resize(maxWeight uint, maxSize int) (evicted int)
- func (c *Cache) Total() (weight uint, num int)
- func (c *Cache) Weight() uint
- type EvictCallback
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 implements a non-thread safe fixed size/weight LRU cache
func NewWithEvict ¶
func NewWithEvict(maxWeight uint, maxSize int, onEvict EvictCallback) (*Cache, error)
NewWeightedLRU constructs an LRU of the given weight and size
func (*Cache) Contains ¶
Contains checks if a key is in the cache, without updating the recent-ness or deleting it for being stale.
func (*Cache) Keys ¶
func (c *Cache) Keys() []interface{}
Keys returns a slice of the keys in the cache, from oldest to newest.
func (*Cache) Peek ¶
Peek returns the key value (or undefined if not found) without updating the "recently used"-ness of the key.
func (*Cache) Remove ¶
Remove removes the provided key from the cache, returning if the key was contained.
func (*Cache) RemoveOldest ¶
RemoveOldest removes the oldest item from the cache.
type EvictCallback ¶
type EvictCallback func(key interface{}, value interface{})
EvictCallback is used to get a callback when a cache entry is evicted
Click to show internal directories.
Click to hide internal directories.