Documentation
¶
Overview ¶
Package cache provides a simple, goroutine safe, cache with a fixed number of entries. Each entry has a per-cache defined TTL. This TTL is reset on both modification and access to the value. As a result, if the cache is full, and no items have expired, when adding a new item, the item with the soonest expiration will be evicted.
It is based on the LRU implementation in golang-lru: github.com/hashicorp/golang-lru
Which in turn is based on the LRU implementation in groupcache: github.com/golang/groupcache/lru
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
// Set a key with value to the cache. Returns true if an item was
// evicted.
Set(key, value interface{}) bool
// Get an item from the cache by key. Returns the value if it exists,
// and a bool stating whether or not it existed.
Get(key interface{}) (interface{}, bool)
// Keys returns a slice of all the keys in the cache
Keys() []interface{}
// Len returns the number of items present in the cache
Len() int
// Cap returns the total number of items the cache can retain
Cap() int
// Purge removes all items from the cache
Purge()
// Del deletes an item from the cache by key. Returns if an item was
// actually deleted.
Del(key interface{}) bool
}
Click to show internal directories.
Click to hide internal directories.