Documentation
¶
Overview ¶
Package lru implements a Least Recently Used cache.
This implementation lets you set the limitations of the cache size based upon a number of entries.
The package also includes a utility called "tailor" for tailoring the cache to a specific key/value type instead of interface{}, allowing you to remove the overhead of runtime type inference.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Get returns the value stored at key "k" and true if found. O(1) operation. Get(k interface{}) (interface{}, bool) // Set adds a value at key "k" of value "v". O(1) operation. Set(k interface{}, v interface{}) error // Remove removes a value at key "k". O(1) operation. Remove(k interface{}) // RemoveOldest removes the oldest value in the cache. O(1) operation. RemoveOldest() // Len returns the current length of the cache. Len() int }
Cache provides the LRU cache.
type Option ¶
type Option func(c *cache)
Option is an optional argument for New().
func NumberLimit ¶
NumberLimit sets a limit to the number of items that can be stored in the Cache before an insertion purges an existing item.
Directories
¶
Path | Synopsis |
---|---|
tailor is a very simplistic program for replacing the key and value types in lru.go with concrete types that do not require any type of runtime reflection.
|
tailor is a very simplistic program for replacing the key and value types in lru.go with concrete types that do not require any type of runtime reflection. |
Click to show internal directories.
Click to hide internal directories.