Documentation
¶
Index ¶
- Constants
- type LRU
- func (lru *LRU) Delete(key string) (prev interface{}, deleted bool)
- func (lru *LRU) Get(key string) (value interface{}, ok bool)
- func (lru *LRU) Len() int
- func (lru *LRU) Range(iter func(key string, value interface{}) bool)
- func (lru *LRU) Resize(size int) (evictedKeys []string, evictedValues []interface{})
- func (lru *LRU) Reverse(iter func(key string, value interface{}) bool)
- func (lru *LRU) Set(key string, value interface{}) (prev interface{}, replaced bool)
- func (lru *LRU) SetEvicted(key string, value interface{}) (prev interface{}, replaced bool, evictedKey string, evictedValue 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.