Documentation ¶
Index ¶
- type CacheConfig
- type ImmunityCache
- func (ic *ImmunityCache) Add(item storage.CacheItem) (ok bool, added bool)
- func (ic *ImmunityCache) Clear()
- func (ic *ImmunityCache) Count() int
- func (ic *ImmunityCache) CountImmune() int
- func (ic *ImmunityCache) ForEachItem(function storage.ForEachItem)
- func (ic *ImmunityCache) Get(key []byte) (value interface{}, ok bool)
- func (ic *ImmunityCache) GetItem(key []byte) (storage.CacheItem, bool)
- func (ic *ImmunityCache) Has(key []byte) bool
- func (ic *ImmunityCache) HasOrAdd(_ []byte, value interface{}, _ int) (ok, evicted bool)
- func (ic *ImmunityCache) ImmunizeKeys(keys [][]byte) (numNowTotal, numFutureTotal int)
- func (ic *ImmunityCache) IsInterfaceNil() bool
- func (ic *ImmunityCache) Keys() [][]byte
- func (ic *ImmunityCache) Len() int
- func (ic *ImmunityCache) MaxSize() int
- func (ic *ImmunityCache) NumBytes() int
- func (ic *ImmunityCache) Peek(key []byte) (value interface{}, ok bool)
- func (ic *ImmunityCache) Put(key []byte, value interface{}, _ int) (evicted bool)
- func (ic *ImmunityCache) RegisterHandler(func(key []byte, value interface{}), string)
- func (ic *ImmunityCache) Remove(key []byte)
- func (ic *ImmunityCache) RemoveOldest()
- func (ic *ImmunityCache) RemoveWithResult(key []byte) bool
- func (ic *ImmunityCache) UnRegisterHandler(_ string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheConfig ¶
type CacheConfig struct { Name string NumChunks uint32 MaxNumItems uint32 MaxNumBytes uint32 NumItemsToPreemptivelyEvict uint32 }
CacheConfig holds cache configuration
func (*CacheConfig) String ¶
func (config *CacheConfig) String() string
String returns a readable representation of the object
type ImmunityCache ¶
type ImmunityCache struct {
// contains filtered or unexported fields
}
ImmunityCache is a cache-like structure
func NewImmunityCache ¶
func NewImmunityCache(config CacheConfig) (*ImmunityCache, error)
NewImmunityCache creates a new cache
func (*ImmunityCache) Add ¶
func (ic *ImmunityCache) Add(item storage.CacheItem) (ok bool, added bool)
Add adds an item in the cache
func (*ImmunityCache) Count ¶
func (ic *ImmunityCache) Count() int
Count returns the number of elements within the map
func (*ImmunityCache) CountImmune ¶
func (ic *ImmunityCache) CountImmune() int
CountImmune returns the number of immunized (current or future) elements within the map
func (*ImmunityCache) ForEachItem ¶
func (ic *ImmunityCache) ForEachItem(function storage.ForEachItem)
ForEachItem iterates over the items in the cache
func (*ImmunityCache) Get ¶
func (ic *ImmunityCache) Get(key []byte) (value interface{}, ok bool)
Get gets an item (payload) by key
func (*ImmunityCache) GetItem ¶
func (ic *ImmunityCache) GetItem(key []byte) (storage.CacheItem, bool)
GetItem gets an item by key
func (*ImmunityCache) Has ¶
func (ic *ImmunityCache) Has(key []byte) bool
Has checks is an item exists
func (*ImmunityCache) HasOrAdd ¶
func (ic *ImmunityCache) HasOrAdd(_ []byte, value interface{}, _ int) (ok, evicted bool)
HasOrAdd adds an item in the cache
func (*ImmunityCache) ImmunizeKeys ¶
func (ic *ImmunityCache) ImmunizeKeys(keys [][]byte) (numNowTotal, numFutureTotal int)
ImmunizeKeys marks items as immune to eviction
func (*ImmunityCache) IsInterfaceNil ¶
func (ic *ImmunityCache) IsInterfaceNil() bool
IsInterfaceNil returns true if there is no value under the interface
func (*ImmunityCache) MaxSize ¶
func (ic *ImmunityCache) MaxSize() int
MaxSize returns the capacity of the cache
func (*ImmunityCache) NumBytes ¶
func (ic *ImmunityCache) NumBytes() int
NumBytes estimates the size of the cache, in bytes
func (*ImmunityCache) Peek ¶
func (ic *ImmunityCache) Peek(key []byte) (value interface{}, ok bool)
Peek gets an item
func (*ImmunityCache) Put ¶
func (ic *ImmunityCache) Put(key []byte, value interface{}, _ int) (evicted bool)
Put adds an item in the cache
func (*ImmunityCache) RegisterHandler ¶
func (ic *ImmunityCache) RegisterHandler(func(key []byte, value interface{}), string)
RegisterHandler is not implemented
func (*ImmunityCache) RemoveOldest ¶
func (ic *ImmunityCache) RemoveOldest()
RemoveOldest is not implemented
func (*ImmunityCache) RemoveWithResult ¶
func (ic *ImmunityCache) RemoveWithResult(key []byte) bool
RemoveWithResult removes an item TODO: In the future, add this method to the "storage.Cacher" interface
func (*ImmunityCache) UnRegisterHandler ¶ added in v1.0.126
func (ic *ImmunityCache) UnRegisterHandler(_ string)
UnRegisterHandler removes the handler from the list