ristretto

package
v0.2.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RistrettoType represents the storage type as a string value.
	RistrettoType = "ristretto"
	// RistrettoTagPattern represents the tag pattern to be used as a key in specified storage.
	RistrettoTagPattern = "gocache_tag_%s"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type RistrettoClientInterface

type RistrettoClientInterface interface {
	Get(key any) (any, bool)
	Set(key, value any, cost int64) bool
	SetWithTTL(key, value any, cost int64, ttl time.Duration) bool
	Del(key any)
	Clear()
	Wait()
}

RistrettoClientInterface represents a dgraph-io/ristretto client.

type RistrettoStore

type RistrettoStore struct {
	// contains filtered or unexported fields
}

RistrettoStore is a store for Ristretto (memory) library.

func NewRistretto

func NewRistretto(client RistrettoClientInterface) *RistrettoStore

NewRistretto creates a new store to Ristretto (memory) library instance.

func (*RistrettoStore) Clear

func (s *RistrettoStore) Clear(_ context.Context) error

Clear resets all data in the store.

func (*RistrettoStore) Del

func (s *RistrettoStore) Del(_ context.Context, key any) error

Delete removes data in Ristretto memory cache for given key identifier.

func (*RistrettoStore) Get

func (s *RistrettoStore) Get(_ context.Context, key any) (any, error)

Get returns data stored from a given key.

func (*RistrettoStore) GetWithTTL

func (s *RistrettoStore) GetWithTTL(ctx context.Context, key any) (any, time.Duration, error)

GetWithTTL returns data stored from a given key and its corresponding TTL.

func (*RistrettoStore) Set

func (s *RistrettoStore) Set(_ context.Context, key any, value any) error

Set defines data in Ristretto memory cache for given key identifier.

func (*RistrettoStore) SetWithTTL

func (s *RistrettoStore) SetWithTTL(ctx context.Context, key any, value any, ttl time.Duration) error

func (*RistrettoStore) Wait

func (s *RistrettoStore) Wait(_ context.Context)

Jump to

Keyboard shortcuts

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