Documentation ¶
Index ¶
- type Cache
- type EvictCallback
- type LRU
- func (l *LRU) Add(key, value interface{}) bool
- func (l *LRU) Contains(key interface{}) bool
- func (l *LRU) Get(key interface{}) (interface{}, bool)
- func (l *LRU) GetOldest() (interface{}, interface{}, bool)
- func (l *LRU) Keys() []interface{}
- func (l *LRU) Len() int
- func (l *LRU) Peek(key interface{}) (interface{}, bool)
- func (l *LRU) Purge()
- func (l *LRU) Remove(key interface{}) bool
- func (l *LRU) RemoveOldest() (interface{}, interface{}, bool)
- func (l *LRU) Resize(size int) (evicted int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Purge 用于完全清理缓存 Purge() // Add 增加一个新值到缓存中,当有旧数据被清理时返回true Add(key, value interface{}) bool // Get 从缓存中查找键值 Get(Key interface{}) (interface{}, bool) // Contains 检查键是否在缓存中,但不更新其最近度 Contains(key interface{}) bool // Peek 返回键值(如果没有找到则未定义),而不更新键的“最近使用”属性 Peek(key interface{}) (interface{}, bool) // Remove 从缓存中删除提供的键,如果包含该键则返回成功 Remove(key interface{}) bool // RemoveOldest 从缓存中删除最旧的实例 RemoveOldest() (interface{}, interface{}, bool) // GetOldest 获取最旧的实例 GetOldest() (interface{}, interface{}, bool) // Keys 返回缓存键的slice, 从最旧的到最新的 Keys() []interface{} // Len 返回缓存中元素的数量 Len() int // Resize 调整缓存大小 Resize(size int) (evicted int) }
Cache LRU 缓存接口.
type EvictCallback ¶
type EvictCallback func(key interface{}, val interface{})
EvictCallback 当缓存实例被清理时的回调方法
Click to show internal directories.
Click to hide internal directories.