Documentation ¶
Overview ¶
Package lru implement a thread safe lfu cache
Index ¶
- Constants
- type LFU
- func (l *LFU) Cap() int
- func (l *LFU) Contains(key interface{}) bool
- func (l *LFU) Get(key interface{}) (value interface{}, ok bool)
- func (l *LFU) GetOrSet(key, value interface{}) (newValue interface{}, isGet bool)
- func (l *LFU) Info() (hits int, misses int, maxSize int, currentSize int)
- func (l *LFU) Keys() []interface{}
- func (l *LFU) Len() int
- func (l *LFU) PopOldest() (key, value interface{})
- func (l *LFU) Purge()
- func (l *LFU) Remove(key interface{}) bool
- func (l *LFU) Set(key, value interface{}) (evicted bool)
Constants ¶
View Source
const (
// default LFU size
Default_LFU_Size = 1024
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LFU ¶
type LFU struct {
// contains filtered or unexported fields
}
LFU implements a thread safe fixed size LFU cache
func (*LFU) GetOrSet ¶
return the value if the key exist, otherwise update the key by given value similar with redis SETNX
func (*LFU) Keys ¶
func (l *LFU) Keys() []interface{}
return all keys the LRU hold from oldest to newest
func (*LFU) PopOldest ¶
func (l *LFU) PopOldest() (key, value interface{})
Remove and return the oldest item from LFU
Click to show internal directories.
Click to hide internal directories.