Documentation ¶
Overview ¶
The implementation borrows heavily from SmallLRUCache (originally by Nathan Schrenk). The object maintains a doubly-linked list of elements in the When an element is accessed it is promoted to the head of the list, and when space is needed the element at the tail of the list (the least recently used element) is evicted.
Index ¶
- type Item
- type LRUCache
- func (lru *LRUCache) Capacity() int64
- func (lru *LRUCache) Clear()
- func (lru *LRUCache) Delete(key string) bool
- func (lru *LRUCache) Get(key string) (v Value, ok bool)
- func (lru *LRUCache) Items() []Item
- func (lru *LRUCache) Keys() []string
- func (lru *LRUCache) Length() int64
- func (lru *LRUCache) Oldest() (oldest time.Time)
- func (lru *LRUCache) Set(key string, value Value)
- func (lru *LRUCache) SetCapacity(capacity int64)
- func (lru *LRUCache) SetIfAbsent(key string, value Value)
- func (lru *LRUCache) Size() int64
- func (lru *LRUCache) Stats() (length, size, capacity int64, oldest time.Time)
- func (lru *LRUCache) StatsJSON() string
- type Value
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
}
func NewLRUCache ¶
func (*LRUCache) SetCapacity ¶
func (*LRUCache) SetIfAbsent ¶
Click to show internal directories.
Click to hide internal directories.