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.
Click to show internal directories.
Click to hide internal directories.