ristretto

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const NoExpiration time.Duration = 0

NoExpiration is used to indicate that data should not expire from the cache.

Variables

View Source
var ErrItemDropped = errors.New("item dropped")

ErrItemDropped signifies that the item to store was not inserted into the cache.

See: https://godoc.org/github.com/dgraph-io/ristretto#Cache.Set

Functions

This section is empty.

Types

type RistrettoStore

type RistrettoStore struct {
	Cache       *ristretto.Cache
	DefaultCost *int64
}

RistrettoStore is used to create an in-memory ristretto cache.

See: https://godoc.org/github.com/dgraph-io/ristretto

func NewRistrettoStore

func NewRistrettoStore(config *ristretto.Config, defaultCost ...int64) *RistrettoStore

NewRistrettoStore creates an in-memory ristretto cache.

See: https://godoc.org/github.com/dgraph-io/ristretto#Config

func (*RistrettoStore) Close

func (r *RistrettoStore) Close()

Close returns the connection back to the pool for storage drivers that utilize a pool. For this driver, it does nothing.

func (*RistrettoStore) Conn

func (r *RistrettoStore) Conn(ctx context.Context) (remember.Cacher, error)

Conn does nothing for this storage driver.

func (*RistrettoStore) Forget

func (r *RistrettoStore) Forget(key string) error

Forget clears the value from the cache for the particular key.

See: https://godoc.org/github.com/dgraph-io/ristretto#Cache.Del

func (*RistrettoStore) ForgetAll

func (r *RistrettoStore) ForgetAll() error

ForgetAll clears all values from the cache. Note that this is not an atomic operation.

See: https://godoc.org/github.com/dgraph-io/ristretto#Cache.Clear

func (*RistrettoStore) Get

func (r *RistrettoStore) Get(key string) (_ interface{}, found bool, _ error)

Get returns a value from the cache if the key exists. It is possible for nil to be returned while found is also true.

See: https://godoc.org/github.com/dgraph-io/ristretto#Cache.Get

func (*RistrettoStore) Set

func (r *RistrettoStore) Set(key string, expiration time.Duration, itemToStore interface{}) error

Set sets a item into the cache for a particular key. The cost is always set to 1, unless over-ridden at creation.

See: https://godoc.org/github.com/dgraph-io/ristretto#Cache.SetWithTTL

func (*RistrettoStore) StorePointer

func (r *RistrettoStore) StorePointer() bool

StorePointer sets whether a storage driver requires itemToStore to be stored as a pointer or as a concrete value.

Jump to

Keyboard shortcuts

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