Documentation ¶
Index ¶
- type EvictCallback
- type LFUDA
- func (l *LFUDA) Age() float64
- func (l *LFUDA) Contains(key interface{}) (ok bool)
- func (l *LFUDA) Get(key interface{}) (interface{}, bool)
- func (l *LFUDA) Keys() []interface{}
- func (l *LFUDA) Len() int
- func (l *LFUDA) Peek(key interface{}) (interface{}, bool)
- func (l *LFUDA) Purge()
- func (l *LFUDA) Remove(key interface{}) bool
- func (l *LFUDA) Set(key interface{}, value interface{}) bool
- func (l *LFUDA) Size() float64
- type LFUDACache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EvictCallback ¶
type EvictCallback func(key interface{}, value interface{})
EvictCallback is used to get a callback when a LFUDA entry is evicted
type LFUDA ¶
type LFUDA struct {
// contains filtered or unexported fields
}
LFUDA is a non-threadsafe fixed size LFU with Dynamic Aging Cache
func NewGDSF ¶ added in v0.3.0
func NewGDSF(size float64, onEvict EvictCallback) *LFUDA
NewGDSF constructs an LFUDA of the given size in bytes and uses the GDSF eviction policy
func NewLFU ¶ added in v0.3.0
func NewLFU(size float64, onEvict EvictCallback) *LFUDA
NewLFU constructs an LFUDA of the given size in bytes and uses the LFU eviction policy
func NewLFUDA ¶
func NewLFUDA(size float64, onEvict EvictCallback) *LFUDA
NewLFUDA constructs an LFUDA of the given size in bytes and uses the LFUDA eviction policy
func (*LFUDA) Contains ¶
Contains checks if a key is in the cache, without updating the recent-ness or deleting it for being stale.
func (*LFUDA) Keys ¶
func (l *LFUDA) Keys() []interface{}
Keys returns a slice of the keys in the cache ordered by frequency
func (*LFUDA) Peek ¶
Peek looks up a key's value from the cache but will not increment the items hit counter
func (*LFUDA) Remove ¶
Remove removes the provided key from the cache, returning if the key was contained
type LFUDACache ¶
type LFUDACache interface { // Adds a value to the cache, returns true if an eviction occurred and // updates the "recently used"-ness of the key. Set(key, value interface{}) bool // Returns key's value from the cache and // updates the "recently used"-ness of the key. #value, isFound Get(key interface{}) (value interface{}, ok bool) // Checks if a key exists in cache without updating the recent-ness. Contains(key interface{}) (ok bool) // Returns key's value without updating the "recently used"-ness of the key. Peek(key interface{}) (value interface{}, ok bool) // Removes a key from the cache. Remove(key interface{}) bool // Returns a slice of the keys in the cache, from oldest to newest. Keys() []interface{} // Returns the number of items in the cache. Len() int // Returns the current size of the cache in bytes. Size() float64 // Clears all cache entries. Purge() // Returns current age factor of the cache Age() float64 }
LFUDACache is the interface for simple LFUDA cache.