Documentation ¶
Index ¶
- func Hash(what []byte) uint64
- type Cache
- func (c *Cache) Add(key string, el interface{}) error
- func (c *Cache) Get(key string) (interface{}, bool)
- func (c *Cache) Len() int
- func (c *Cache) Remove(key string)
- func (c *Cache) SetEvict(e EvictFn)
- func (c *Cache) UpdateAdd(key string, update func(*interface{}) interface{}, add func() interface{}) interface{}
- type EvictFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is cache with a customizable eviction policy.
func (*Cache) Add ¶
Add adds a new element to the cache. If the element already exists it is overwritten.
func (*Cache) Len ¶
Len returns an estimate number of elements in the cache. This is an estimate, because each shard is locked one at a time, and items can be added/removed from other shards as each shard is counted.
Click to show internal directories.
Click to hide internal directories.