Documentation ¶
Index ¶
- type LRUCache
- func (c *LRUCache) Clear()
- func (c *LRUCache) Get(key []byte) (value interface{}, ok bool)
- func (c *LRUCache) Has(key []byte) bool
- func (c *LRUCache) HasOrAdd(key []byte, value interface{}) (found, evicted bool)
- func (c *LRUCache) IsInterfaceNil() bool
- func (c *LRUCache) Keys() [][]byte
- func (c *LRUCache) Len() int
- func (c *LRUCache) MaxSize() int
- func (c *LRUCache) Peek(key []byte) (value interface{}, ok bool)
- func (c *LRUCache) Put(key []byte, value interface{}) (evicted bool)
- func (c *LRUCache) RegisterHandler(handler func(key []byte, value interface{}))
- func (c *LRUCache) Remove(key []byte)
- func (c *LRUCache) RemoveOldest()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LRUCache ¶
type LRUCache struct {
// contains filtered or unexported fields
}
LRUCache implements a Least Recently Used eviction cache
func (*LRUCache) Has ¶
Has checks if a key is in the cache, without updating the recent-ness or deleting it for being stale.
func (*LRUCache) HasOrAdd ¶
HasOrAdd checks if a key is in the cache without updating the recent-ness or deleting it for being stale, and if not, adds the value. Returns whether found and whether an eviction occurred.
func (*LRUCache) IsInterfaceNil ¶
IsInterfaceNil returns true if there is no value under the interface
func (*LRUCache) MaxSize ¶
MaxSize returns the maximum number of items which can be stored in cache.
func (*LRUCache) Peek ¶
Peek returns the key value (or undefined if not found) without updating the "recently used"-ness of the key.
func (*LRUCache) RegisterHandler ¶
RegisterHandler registers a new handler to be called when a new data is added
func (*LRUCache) RemoveOldest ¶
func (c *LRUCache) RemoveOldest()
RemoveOldest removes the oldest item from the cache.