Documentation
¶
Index ¶
- Constants
- type LRU
- func (lru *LRU) Delete(key interface{}) (prev interface{}, deleted bool)
- func (lru *LRU) Get(key interface{}) (value interface{}, ok bool)
- func (lru *LRU) Len() int
- func (lru *LRU) Range(iter func(key interface{}, value interface{}) bool)
- func (lru *LRU) Resize(size int) (evictedKeys []interface{}, evictedValues []interface{})
- func (lru *LRU) Reverse(iter func(key interface{}, value interface{}) bool)
- func (lru *LRU) Set(key interface{}, value interface{}) (prev interface{}, replaced bool)
- func (lru *LRU) SetEvicted(key interface{}, value interface{}) (prev interface{}, replaced bool, evictedKey interface{}, ...)
Constants ¶
const DefaultSize = 256
DefaultSize is the default maximum size of an LRU cache before older items get automatically evicted.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LRU ¶
type LRU struct {
// contains filtered or unexported fields
}
LRU implements an LRU cache
func (*LRU) Range ¶
Range iterates over all key/values in the order of most recently to least recently used items. It's not safe to call other LRU operations while ranging.
func (*LRU) Resize ¶
Resize sets the maximum size of an LRU cache. If this value is less than the number of items currently in the cache, then items will be evicted. Returns evicted items. This operation will panic if the size is less than one.
func (*LRU) Reverse ¶
Reverse iterates over all key/values in the order of least recently to most recently used items. It's not safe to call other LRU operations while ranging.
func (*LRU) SetEvicted ¶
func (lru *LRU) SetEvicted(key interface{}, value interface{}) ( prev interface{}, replaced bool, evictedKey interface{}, evictedValue interface{}, evicted bool)
SetEvicted sets or replaces a value for a key. If this operation causes an eviction then the evicted item is returned.