Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LruCache ¶
LruCache is a kind of LRU cache. Objects that are too old are removed, and if the cache is full, the oldest item(s) will be removed. When an item is set more than once, it is pushed to the end so its last to be removed. Limits are approximate, as garbage collecting will randomly happen. Also, in order to prevent memory thrashing, strict order is not preserved, but items will fall out more or less in LRU order. Someday we may offer a backing store version to extend the size of the cache to disk or some other kind of storage If the item has a "Removed" function, that function will be called when the item falls out of the cache. If the item has a "Cleanup" function, that function will be called when the item is removed from memory. If the cache has a backing store, it may be removed from memory, but still in the disk-based cache.
func NewLruCache ¶
Create and return a new cache. maxItemCount is the maximum number of items the cache can hold ttl is the age in seconds past when items will be removed
func (*LruCache) Get ¶
Get returns the item based on its id, and updates its access time. If not found, it will return nil.