Documentation ¶
Overview ¶
Package LRU implements an in-memory Least-Recently-Used cache.
Index ¶
- Variables
- type Cache
- func (c *Cache) Clear()
- func (c *Cache) Get(key interface{}) (interface{}, bool)
- func (c *Cache) Keys() []interface{}
- func (c *Cache) Peek(key interface{}) (interface{}, bool)
- func (c *Cache) Put(key, value interface{}) error
- func (c *Cache) Remove(key interface{}) bool
- func (c *Cache) Size() uint64
- type OnEvictFunc
- type Option
- type Sizeable
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.