Documentation ¶
Index ¶
- type Cache
- func (c *Cache) Add(key Key, value interface{})
- func (c *Cache) Clear()
- func (c *Cache) Get(key Key) (value interface{}, ok bool)
- func (c *Cache) GetHits(key Key) (hits int64, ok bool)
- func (c *Cache) Info(callback func(Key, interface{}, int64))
- func (c *Cache) Len() int
- func (c *Cache) Remove(key Key)
- type Key
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 specifies a callback function to be // executed when an entry is purged from the cache. OnEvicted func(key Key, value interface{}) sync.RWMutex // contains filtered or unexported fields }
func NewCache ¶
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.
type Key ¶
type Key interface{}
A Key may be any value that is comparable. See http://golang.org/ref/spec#Comparison_operators
Click to show internal directories.
Click to hide internal directories.