Documentation ¶
Index ¶
- type Cache
- func (c *Cache) Add(key, value interface{}) (evicted bool)
- func (c *Cache) Contains(key interface{}) bool
- func (c *Cache) ContainsOrAdd(key, value interface{}) (ok, evicted bool)
- func (c *Cache) Get(key interface{}) (value interface{}, ok bool)
- func (c *Cache) GetOldest() (key interface{}, value interface{}, ok bool)
- func (c *Cache) Keys() []interface{}
- func (c *Cache) Len() int
- func (c *Cache) Peek(key interface{}) (value interface{}, ok bool)
- func (c *Cache) PeekOrAdd(key, value interface{}) (previous interface{}, ok, evicted bool)
- func (c *Cache) Purge()
- func (c *Cache) Remove(key interface{}) (present bool)
- func (c *Cache) RemoveOldest() (key interface{}, value interface{}, ok bool)
- func (c *Cache) Resize(size int) (evicted int)
- type Fifo
- func (c *Fifo) Add(key, value interface{}) (evicted bool)
- func (c *Fifo) Contains(key interface{}) (ok bool)
- func (c *Fifo) Get(key interface{}) (value interface{}, ok bool)
- func (c *Fifo) GetOldest() (key interface{}, value interface{}, ok bool)
- func (c *Fifo) Keys() []interface{}
- func (c *Fifo) Len() int
- func (c *Fifo) Peek(key interface{}) (value interface{}, ok bool)
- func (c *Fifo) Purge()
- func (c *Fifo) Remove(key interface{}) (present bool)
- func (c *Fifo) RemoveOldest() (key interface{}, value interface{}, ok bool)
- func (c *Fifo) Resize(size int) (evicted int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a thread-safe fixed size fifo cache.
func (*Cache) Contains ¶
Contains checks if a key is in the cache, without updating the recent-ness or deleting it for being stale.
func (*Cache) ContainsOrAdd ¶
ContainsOrAdd checks if a key is in the cache without updating the recent-ness or deleting it for being stale, and if not, adds the value. Returns whether found and whether an eviction occurred.
func (*Cache) Keys ¶
func (c *Cache) Keys() []interface{}
Keys returns a slice of the keys in the cache, from oldest to newest.
func (*Cache) Peek ¶
Peek returns the key value (or undefined if not found) without updating the "recently used"-ness of the key.
func (*Cache) PeekOrAdd ¶
PeekOrAdd checks if a key is in the cache without updating the recent-ness or deleting it for being stale, and if not, adds the value. Returns whether found and whether an eviction occurred.
func (*Cache) RemoveOldest ¶
RemoveOldest removes the oldest item from the cache.
type Fifo ¶
type Fifo struct {
// contains filtered or unexported fields
}
Fifo implements a non-thread safe fixed size Fifo cache
func (*Fifo) Contains ¶
Contains checks if a key is in the cache, without updating the recent-ness or deleting it for being stale.
func (*Fifo) Keys ¶
func (c *Fifo) Keys() []interface{}
Keys returns a slice of the keys in the cache, from oldest to newest.
func (*Fifo) Peek ¶
Peek returns the key value (or undefined if not found) without updating the "recently used"-ness of the key.
func (*Fifo) Remove ¶
Remove removes the provided key from the cache, returning if the key was contained.
func (*Fifo) RemoveOldest ¶
RemoveOldest removes the oldest item from the cache.