Documentation
¶
Overview ¶
Package lru implements an LRU cache. Adapted from golang.org/x/build/internal/lru.
Index ¶
Constants ¶
const LongDuration = 365 * 24 * time.Hour
LongDuration is one year; use when you don't really want a timeout on the cache (e.g. in tests).
Variables ¶
var ErrCacheMiss = errors.New("lru cache miss")
ErrCacheMiss is an error indicating that the value is not in the cache.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is an LRU cache, safe for concurrent access.
func (*Cache) Get ¶
Get fetches the key's value from the cache. The error result will be nil if the item was found. Note that while the entry will be moved to the front of the queue, its expiration clock will not restart, and it will be removed if it has expired.
func (*Cache) RemoveOldest ¶
RemoveOldest removes the oldest item in the cache and returns its key and value. If the cache is empty, two empty strings are returned.