cache

package
v4.40.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2022 License: MIT Imports: 7 Imported by: 5 modules, 6 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvictOnSuccess added in v4.39.0

func EvictOnSuccess(ctx context.Context, redisClient RedisClient, key string, err error) error

EvictOnSuccess evict the given key if there is no error

func Retrieve added in v4.28.0

func Retrieve[T any](ctx context.Context, redisClient RedisClient, key string, onMiss func(context.Context) (T, error), duration time.Duration) (item T, err error)

Retrieve loads an item from the cache for given key or retrieve it (and store it in cache after)

Types

type RedisClient added in v4.28.0

type RedisClient interface {
	Load(ctx context.Context, key string) (string, error)
	Store(ctx context.Context, key string, value any, duration time.Duration) error
	Delete(ctx context.Context, keys ...string) error
}

RedisClient for caching response

Jump to

Keyboard shortcuts

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