Documentation ¶
Overview ¶
Package LRU implements an in-memory Least-Recently-Used cache.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrTooLarge = errors.New("lru: value size exceeds maximum capacity")
ErrTooLarge is the error returned when a value is too large for the cache.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
Cache is an LRU cache instance.
func (*Cache) Get ¶
Get returns the value associated with the key and true if it is present in the cache, and the entry is moved to the most-recently-used position.
func (*Cache) Keys ¶
func (c *Cache) Keys() []interface{}
Keys returns the keys for every entry in the cache, from the least-recently-used to the most-recently-used.
func (*Cache) Peek ¶
Peek returns the value associated with the key and true if it is present in the cache, without altering the access time of the entry.
func (*Cache) Put ¶
Put inserts the key/value pair into the cache. If the key is already present, the value is updated, and the entry is moved to the most-recently-used position.
type OnEvictFunc ¶
type OnEvictFunc func(key, value interface{})
OnEvictFunc is the function signature for the on-evict callback.
Note: The callback does not support calling routines on it's associated cache instance.
type Option ¶
Option is a configuration option used when instantiating a cache.