Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { storage.BatchedStore // contains filtered or unexported fields }
Cache is a wrapper around a storage.Store that adds a layer of in-memory caching for the Get and Has operations.
func MustWrap ¶
func MustWrap(store storage.BatchedStore, capacity int) *Cache
MustWrap is like Wrap but panics on error.
func Wrap ¶
func Wrap(store storage.BatchedStore, capacity int) (*Cache, error)
Wrap adds a layer of in-memory caching to storage.Reader Get and Has operations. It returns an error if the capacity is less than or equal to zero or if the given store implements storage.Tx
func (*Cache) Delete ¶
Delete implements storage.Store interface. On a call it also removes the item from the cache.
func (*Cache) Get ¶
Get implements storage.Store interface. On a call it tries to first retrieve the item from cache. If the item does not exist in cache, it tries to retrieve it from the underlying store.
func (*Cache) Has ¶
Has implements storage.Store interface. On a call it tries to first retrieve the item from cache. If the item does not exist in cache, it tries to retrieve it from the underlying store.
func (*Cache) Metrics ¶
func (c *Cache) Metrics() []prometheus.Collector