trristretto

package module
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: MIT Imports: 7 Imported by: 0

README

trcache ristretto GoDoc

This is a trcache wrapper for Ristretto.

Info

Ristretto library
info
Generics No
Key types any
Value types any
TTL Yes
wrapper
info
Default codec ForwardCodec
Default key codec N/A

Installation

go get github.com/rrgmc/trcache/cache/ristretto

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithDefaultDuration

func WithDefaultDuration[K comparable, V any](duration time.Duration) trcache.RootOption

func WithEventualConsistency

func WithEventualConsistency[K comparable, V any](eventualConsistency bool) trcache.RootOption

func WithSetCost

func WithSetCost[K comparable, V any](cost int64) trcache.SetOption

func WithValidator

func WithValidator[K comparable, V any](validator trcache.Validator[V]) trcache.RootOption

func WithValueCodec

func WithValueCodec[K comparable, V any](valueCodec trcache.Codec[V]) trcache.RootOption

Types

type Cache

type Cache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func New

func New[K comparable, V any](cache *ristretto.Cache,
	options ...trcache.RootOption) (*Cache[K, V], error)

func (*Cache[K, V]) Delete

func (c *Cache[K, V]) Delete(ctx context.Context, key K,
	options ...trcache.DeleteOption) error

func (*Cache[K, V]) Get

func (c *Cache[K, V]) Get(ctx context.Context, key K,
	options ...trcache.GetOption) (V, error)

func (*Cache[K, V]) Handle

func (c *Cache[K, V]) Handle() *ristretto.Cache

func (*Cache[K, V]) Name

func (c *Cache[K, V]) Name() string

func (*Cache[K, V]) Set

func (c *Cache[K, V]) Set(ctx context.Context, key K, value V,
	options ...trcache.SetOption) error

type RefreshCache

type RefreshCache[K comparable, V any] struct {
	*Cache[K, V]
	// contains filtered or unexported fields
}

func NewRefresh

func NewRefresh[K comparable, V any](cache *ristretto.Cache,
	options ...trcache.RootOption) (*RefreshCache[K, V], error)

func (*RefreshCache[K, V]) GetOrRefresh

func (c *RefreshCache[K, V]) GetOrRefresh(ctx context.Context, key K, options ...trcache.RefreshOption) (V, error)

Jump to

Keyboard shortcuts

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