Documentation ¶
Index ¶
- type Element
- type LRUCache
- func (lc *LRUCache) Back() *Element
- func (lc *LRUCache) Capacity() int
- func (lc *LRUCache) Delete(key interface{})
- func (lc *LRUCache) Front() *Element
- func (lc *LRUCache) Get(key interface{}) (interface{}, bool)
- func (lc *LRUCache) Len() int
- func (lc *LRUCache) Put(key interface{}, value interface{})
- func (lc *LRUCache) Range(f func(key, value interface{}) bool)
- func (lc *LRUCache) Update(key interface{}, f func(value *interface{}))
- type SyncCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element struct { Key interface{} Value interface{} // contains filtered or unexported fields }
Element - node to store cache item
type LRUCache ¶
type LRUCache struct {
// contains filtered or unexported fields
}
LRUCache - a data structure that is efficient to insert/fetch/delete cache items [both O(1) time complexity]
func (*LRUCache) Delete ¶
func (lc *LRUCache) Delete(key interface{})
Delete - delete item by key from lru cache
func (*LRUCache) Put ¶
func (lc *LRUCache) Put(key interface{}, value interface{})
Put - put a cache item into lru cache
type SyncCache ¶
type SyncCache struct {
// contains filtered or unexported fields
}
SyncCache - concurrent cache structure
func NewSyncCache ¶
NewSyncCache - create sync cache `capacity` is lru cache length of each bucket store `capacity * bucket` count of element in SyncCache at most `timeout` is in seconds
Click to show internal directories.
Click to hide internal directories.