cache

package
v2.2.0-rc5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	storage.IndexStore
	// 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 Wrap

func Wrap(store storage.IndexStore, 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) Close added in v2.1.0

func (c *Cache) Close() error

func (*Cache) Delete

func (c *Cache) Delete(i storage.Item) error

Delete implements storage.Store interface. On a call it also removes the item from the cache.

func (*Cache) Get

func (c *Cache) Get(i storage.Item) error

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

func (c *Cache) Has(k storage.Key) (bool, error)

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

func (*Cache) Put

func (c *Cache) Put(i storage.Item) error

Put implements storage.Store interface. On a call it also inserts the item into the cache so that the next call to Put and Has will be able to retrieve the item from cache.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL