cache

package
v4.63.4 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 13 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bypass added in v4.59.0

func Bypass(ctx context.Context) context.Context

func IsBypassed added in v4.59.0

func IsBypassed(ctx context.Context) bool

Types

type App

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

func New

func New[K comparable, V any](client RedisClient, toKey func(K) string, onMiss fetch[K, V], tracerProvider trace.TracerProvider) *App[K, V]

func (*App[K, V]) EvictOnSuccess added in v4.47.2

func (a *App[K, V]) EvictOnSuccess(ctx context.Context, item K, err error) error

func (*App[K, V]) Get

func (a *App[K, V]) Get(ctx context.Context, id K) (V, error)

func (App[K, V]) List added in v4.47.1

func (a App[K, V]) List(ctx context.Context, onMissError func(K, error) bool, items ...K) (outputs []V, err error)

If onMissError returns false, List stops by returning an error

func (App[K, V]) Store added in v4.47.3

func (a App[K, V]) Store(ctx context.Context, id K, value V) error

func (*App[K, V]) WithExtendOnHit added in v4.63.0

func (a *App[K, V]) WithExtendOnHit() *App[K, V]

func (*App[K, V]) WithMaxConcurrency added in v4.63.0

func (a *App[K, V]) WithMaxConcurrency(concurrency int) *App[K, V]

func (*App[K, V]) WithMissMany added in v4.53.4

func (a *App[K, V]) WithMissMany(cb fetchMany[K, V]) *App[K, V]

func (*App[K, V]) WithRead added in v4.62.0

func (a *App[K, V]) WithRead(client RedisClient) *App[K, V]

func (*App[K, V]) WithSerializer added in v4.62.0

func (a *App[K, V]) WithSerializer(serializer Serializer[V]) *App[K, V]

func (*App[K, V]) WithTTL added in v4.63.0

func (a *App[K, V]) WithTTL(ttl time.Duration) *App[K, V]

type IndexedItems added in v4.53.6

type IndexedItems[K comparable] map[K]int

func (IndexedItems[K]) Items added in v4.53.6

func (ii IndexedItems[K]) Items() []K

type JSONSerializer added in v4.62.0

type JSONSerializer[V any] struct{}

func (JSONSerializer[V]) Decode added in v4.62.0

func (JSONSerializer[V]) Decode(payload []byte) (V, error)

func (JSONSerializer[V]) Encode added in v4.62.0

func (JSONSerializer[V]) Encode(payload V) ([]byte, error)

type RedisClient added in v4.28.0

type RedisClient interface {
	Enabled() bool
	Load(ctx context.Context, key string) ([]byte, error)
	LoadMany(ctx context.Context, keys ...string) ([]string, error)
	Store(ctx context.Context, key string, value any, ttl time.Duration) error
	Delete(ctx context.Context, keys ...string) error
	Expire(ctx context.Context, ttl time.Duration, keys ...string) error
	Pipeline() redis.Pipeliner
}

type Serializer added in v4.62.0

type Serializer[V any] interface {
	Encode(V) ([]byte, error)
	Decode([]byte) (V, error)
}

type StringSerializer added in v4.62.0

type StringSerializer struct{}

func (StringSerializer) Decode added in v4.62.0

func (StringSerializer) Decode(payload []byte) (string, error)

func (StringSerializer) Encode added in v4.62.0

func (StringSerializer) Encode(payload string) ([]byte, error)

Jump to

Keyboard shortcuts

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