type Clock … type realClock … func (realClock) Now() time.Time { … } type LRUExpireCache … // NewLRUExpireCache creates an expiring cache with the given size func NewLRUExpireCache(maxSize int) *LRUExpireCache { … } // NewLRUExpireCacheWithClock creates an expiring cache with the given size, using the specified clock to obtain the current time. func NewLRUExpireCacheWithClock(maxSize int, clock Clock) *LRUExpireCache { … } type cacheEntry … // Add adds the value to the cache at key with the specified maximum duration. func (c *LRUExpireCache) Add(key interface{ … } // Get returns the value at the specified key from the cache if it exists and is not // expired, or returns false. func (c *LRUExpireCache) Get(key interface{ … } // Remove removes the specified key from the cache if it exists func (c *LRUExpireCache) Remove(key interface{ … } // RemoveAll removes all keys that match predicate. func (c *LRUExpireCache) RemoveAll(predicate func(key any) bool) { … } // Keys returns all unexpired keys in the cache. // // Keep in mind that subsequent calls to Get() for any of the returned keys // might return "not found". // // Keys are returned ordered from least recently used to most recently used. func (c *LRUExpireCache) Keys() []interface{ … }