Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("key not found")
Functions ¶
This section is empty.
Types ¶
type ARCCache ¶ added in v0.1.5
type ARCCache struct {
// contains filtered or unexported fields
}
ARCCache is improved LRU cache, that tracks both recency and frequency of use. See: https://ieeexplore.ieee.org/document/1297303.
type Cache ¶
type Cache interface {
// Set inserts or updates the specified key-value pair with an expiration time.
Set(key string, value interface{}, expiry time.Duration) error
// Get returns the value for specified key if it is present in the cache.
Get(key string) (interface{}, error)
}
Cache is common interface of cache.
func NewCache ¶
func NewCache(capacity int, policy EvictionPolicy) Cache
NewCache returns cache with selected eviction policy.
type EvictionPolicy ¶ added in v0.1.4
type EvictionPolicy int
const ( // Discards the least recently used items first. LRU EvictionPolicy = iota // Discards the least frequently used items first. LFU // Adaptive replacement cache policy. ARC )
type LFUCache ¶
type LFUCache struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.