package lru
import "k8s.io/kubernetes/Godeps/_workspace/src/github.com/golang/groupcache/lru"
Package lru implements an LRU cache.
Index ¶
- type Cache
- func New(maxEntries int) *Cache
- func (c *Cache) Add(key Key, value interface{})
- func (c *Cache) Get(key Key) (value interface{}, ok bool)
- func (c *Cache) Len() int
- func (c *Cache) Remove(key Key)
- func (c *Cache) RemoveOldest()
- type Key
Types ¶
type Cache ¶
type Cache struct { // MaxEntries is the maximum number of cache entries before // an item is evicted. Zero means no limit. MaxEntries int // OnEvicted optionally specificies a callback function to be // executed when an entry is purged from the cache. OnEvicted func(key Key, value interface{}) // contains filtered or unexported fields }
Cache is an LRU cache. It is not safe for concurrent access.
func New ¶
New creates a new Cache. If maxEntries is zero, the cache has no limit and it's assumed that eviction is done by the caller.
func (*Cache) Add ¶
Add adds a value to the cache.
func (*Cache) Get ¶
Get looks up a key's value from the cache.
func (*Cache) Len ¶
Len returns the number of items in the cache.
func (*Cache) Remove ¶
Remove removes the provided key from the cache.
func (*Cache) RemoveOldest ¶
func (c *Cache) RemoveOldest()
RemoveOldest removes the oldest item from the cache.
type Key ¶
type Key interface{}
A Key may be any value that is comparable. See http://golang.org/ref/spec#Comparison_operators
Source Files ¶
lru.go
- Version
- v1.1.9-beta.0
- Published
- Feb 23, 2016
- Platform
- linux/amd64
- Imports
- 1 packages
- Last checked
- 2 seconds ago –
Tools for package owners.