Documentation
¶
Index ¶
- Variables
- func CacheIncrBy(rdb redis.UniversalClient, key string, value int64) error
- func CacheIncrByCtx(ctx context.Context, rdb redis.UniversalClient, key string, value int64) error
- func CacheIncrByToPipe(pipe redis.Pipeliner, key string, value int64)
- func CacheIncrByToPipeCtx(ctx context.Context, pipe redis.Pipeliner, key string, value int64)
- func DeleteCache(rdb redis.UniversalClient, key string) error
- func DeleteCacheCtx(ctx context.Context, rdb redis.UniversalClient, key string) error
- func DeleteCacheToPipe(pipe redis.Pipeliner, keys ...string)
- func DeleteCacheToPipeCtx(ctx context.Context, pipe redis.Pipeliner, keys ...string)
- func QueryWithCache[T any](rdb redis.UniversalClient, key string, model *T, query QueryFunc[*T], ...) (bool, error)
- type CacheConfig
- type Option
- type QueryFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultCacheTime 默认缓存时间,30min DefaultCacheTime = 30 * time.Minute // DefaultCacheTimeDiff 默认缓存时间的上下偏差,5min DefaultCacheTimeDiff = 5 * time.Minute )
Functions ¶
func CacheIncrBy ¶ added in v1.0.4
CacheIncrBy 如果只缓存了一个整数,可以修改缓存,让这个整数增加value
func CacheIncrByCtx ¶ added in v1.0.6
CacheIncrByCtx 如果只缓存了一个整数,可以修改缓存,让这个整数增加value
func CacheIncrByToPipe ¶ added in v1.0.4
CacheIncrByToPipe 将缓存的整数增加value。会把操作加入pipe,不会执行。一次只能添加一个
func CacheIncrByToPipeCtx ¶ added in v1.0.6
CacheIncrByToPipeCtx 将缓存的整数增加value。会把操作加入pipe,不会执行。一次只能添加一个
func DeleteCacheCtx ¶ added in v1.0.6
DeleteCacheCtx 删除缓存
func DeleteCacheToPipe ¶ added in v1.0.2
func DeleteCacheToPipe(pipe redis.Pipeliner, keys ...string)
DeleteCacheToPipe 将删除缓存的操作加入pipe,不会执行
func DeleteCacheToPipeCtx ¶ added in v1.0.6
DeleteCacheToPipeCtx 将删除缓存的操作加入pipe,不会执行
Types ¶
type CacheConfig ¶
type CacheConfig struct {
// contains filtered or unexported fields
}
type Option ¶
type Option func(c *CacheConfig)
func FlushCacheTime ¶ added in v1.0.6
FlushCacheTime 在命中缓存时刷新缓存时间,默认为false
func WithCacheTime ¶
WithCacheTime 指定缓存时间,默认为 30 min
func WithCacheTimeDiff ¶ added in v1.0.6
WithCacheTimeDiff 指定缓存时间上下偏差,默认为 5 min
func WithContext ¶
WithContext 指定使用redis时的context,默认为background
func WriteCache ¶ added in v1.0.3
WriteCache 是否在缓存未命中时,写入缓存,默认为true
Click to show internal directories.
Click to hide internal directories.