Documentation ¶
Overview ¶
Package lrucache provides a very basic LRU cache implementation.
The lru package provides a very basic LRU cache implementation
Index ¶
- type Cache
- type LRUCache
- func (c *LRUCache) Add(key, value interface{}) (evicted bool)
- func (c *LRUCache) Contains(key interface{}) (ok bool)
- func (c *LRUCache) Get(key interface{}) (value interface{}, ok bool)
- func (c *LRUCache) Keys() []interface{}
- func (c *LRUCache) Length() int
- func (c *LRUCache) Purge()
- func (c *LRUCache) Remove(key interface{}) (present bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Add a new value to the cache and updates the recent-ness. Returns true if an eviction occurred. Add(key, value interface{}) bool // Return a key's value if found in the cache and updates the recent-ness. Get(key interface{}) (value interface{}, ok bool) // Check if a key exists without updating the recent-ness. Contains(key interface{}) (ok bool) // Remove a key from the cache. Remove(key interface{}) bool // Return a slice which all keys ordered by newest to oldest. Keys() []interface{} // Return number of entry in the cache. Length() int // Remove all entries form the cache. Purge() }
Cache defines the interface for the LRU cache
type LRUCache ¶
type LRUCache struct {
// contains filtered or unexported fields
}
LRU struct to represent the LRU cache
func NewLRUCache ¶
New constructs a new cache instance
Click to show internal directories.
Click to hide internal directories.