import "github.com/hashicorp/vault/vendor/github.com/hashicorp/golang-lru/simplelru"
type EvictCallback func(key interface{}, value interface{})
EvictCallback is used to get a callback when a cache entry is evicted
type LRU struct {
// contains filtered or unexported fields
}
LRU implements a non-thread safe fixed size LRU cache
func NewLRU(size int, onEvict EvictCallback) (*LRU, error)
NewLRU constructs an LRU of the given size
Add adds a value to the cache. Returns true if an eviction occurred.
Contains checks if a key is in the cache, without updating the recent-ness or deleting it for being stale.
Get looks up a key's value from the cache.
GetOldest returns the oldest entry
Keys returns a slice of the keys in the cache, from oldest to newest.
Len returns the number of items in the cache.
Peek returns the key value (or undefined if not found) without updating the "recently used"-ness of the key.
Purge is used to completely clear the cache.
Remove removes the provided key from the cache, returning if the key was contained.
RemoveOldest removes the oldest item from the cache.
Resize changes the cache size.
type LRUCache interface { // Adds a value to the cache, returns true if an eviction occurred and // updates the "recently used"-ness of the key. Add(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 // Removes the oldest entry from cache. RemoveOldest() (interface{}, interface{}, bool) // Returns the oldest entry from the cache. #key, value, isFound GetOldest() (interface{}, 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 // Clears all cache entries. Purge() // Resizes cache, returning number evicted Resize(int) int }
LRUCache is the interface for simple LRU cache.
Package simplelru imports 2 packages (graph). Updated 2019-09-10. Refresh now. Tools for package owners.