cache

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NewStat = cache.NewStat
)

Functions

This section is empty.

Types

type BatchCache

type BatchCache interface {
	cache.Cache

	// Takes takes results from cache first, if not found,
	// query from DB and set cache using c.expiry, then return the result.
	Takes(query func(keys ...string) (map[string]any, error),
		cacheF func(k, v string) (any, error), keys ...string) error
	// TakesCtx takes results from cache first, if not found,
	// query from DB and set cache using c.expiry, then return the result.
	TakesCtx(ctx context.Context, query func(keys ...string) (map[string]any, error),
		cacheF func(k, v string) (any, error), keys ...string) error
	// TakesWithExpire takes results from cache first, if not found,
	// query from DB and set cache using given expire, then return the result.
	TakesWithExpire(query func(expire time.Duration, keys ...string) (map[string]any, error),
		cacheF func(k, v string) (any, error), keys ...string) error
	// TakesWithExpireCtx takes results from cache first, if not found,
	// query from DB and set cache using given expire, then return the result.
	TakesWithExpireCtx(ctx context.Context, query func(expire time.Duration, keys ...string) (map[string]any, error),
		cacheF func(k, v string) (any, error), keys ...string) error
}

BatchCache extends cache.Cache with batch operations.

func New

func New(c cache.ClusterConf, barrier syncx.SingleFlight, st *cache.Stat,
	errNotFound error, opts ...cache.Option) BatchCache

New returns a BatchCache.

func NewNode

func NewNode(rds *redis.Redis, barrier syncx.SingleFlight, st *cache.Stat,
	errNotFound error, opts ...cache.Option) BatchCache

NewNode returns a BatchCache backed by a single redis node.

type CacheConf

type CacheConf = cache.CacheConf

type Option

type Option = cache.Option

Jump to

Keyboard shortcuts

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