Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("key not found")
Functions ¶
This section is empty.
Types ¶
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 )
type LFUCache ¶
type LFUCache struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.