Documentation ¶
Index ¶
- type EvictCallback
- type LRU
- func (c *LRU) Add(key, value any) (evicted bool)
- func (c *LRU) Contains(key any) (ok bool)
- func (c *LRU) Get(key any) (value any, ok bool)
- func (c *LRU) GetOldest() (key, value any, ok bool)
- func (c *LRU) Keys() []any
- func (c *LRU) Len() int
- func (c *LRU) Peek(key any) (value any, ok bool)
- func (c *LRU) Purge()
- func (c *LRU) Remove(key any) (present bool)
- func (c *LRU) RemoveOldest() (key, value any, ok bool)
- func (c *LRU) Resize(size int) (evicted int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EvictCallback ¶
EvictCallback is used to get a callback when a cache entry is evicted
type LRU ¶
type LRU struct {
// contains filtered or unexported fields
}
LRU implements a non-thread safe fixed size LRU cache
func New ¶
func New(size int, onEvict EvictCallback) *LRU
NewLRU constructs an LRU of the given size
func (*LRU) Contains ¶
Contains checks if a key is in the cache, without updating the recent-ness or deleting it for being stale.
func (*LRU) Peek ¶
Peek returns the key value (or undefined if not found) without updating the "recently used"-ness of the key.
func (*LRU) Remove ¶
Remove removes the provided key from the cache, returning if the key was contained.
func (*LRU) RemoveOldest ¶
RemoveOldest removes the oldest item from the cache.
Click to show internal directories.
Click to hide internal directories.