Versions in this module Expand all Collapse all v1 v1.0.0 Apr 27, 2023 Changes in this version + const DefaultSingleFlightGroupNum + const LevelDebug + const LevelError + const LevelInfo + const LevelWarn + const TTLNoExpire + var ErrInvalidNum = errors.New("Invalid num") + func Decode(b []byte, ptr interface{}) error + func Encode(val interface{}) ([]byte, error) + func SetDefaultLogger(newLogger Logger) + type BatchSetParams struct + ExpireSecondsSlice []int + Keys []string + Values []interface{} + type DefaultLogger struct + func (l *DefaultLogger) Errorf(ctx context.Context, format string, args ...interface{}) + func (l *DefaultLogger) Infof(ctx context.Context, format string, args ...interface{}) + type FallbackFunc func() (interface{}, error) + type LogData struct + Content string + Level string + type Logger interface + Errorf func(ctx context.Context, format string, args ...interface{}) + Infof func(ctx context.Context, format string, args ...interface{}) + func GetDefaultLogger() Logger + type MgetBatchFallbackFunc func(fallbackIndexes []int) (map[int]interface{}, error) + type MgetFallbackFunc func(fallbackIndex int) (interface{}, error) + type Option interface + Apply func(*RedisUtil) + func OptionLogger(logger Logger) Option + func OptionSingleFlightGroupNum(num int) Option + type OptionFunc func(cacheUtil *RedisUtil) + func (of OptionFunc) Apply(cacheUtil *RedisUtil) + type RedisUtil struct + func NewRedisUtil(pool *redis.Pool, options ...Option) *RedisUtil + func (ru *RedisUtil) BatchSet(ctx context.Context, params *BatchSetParams) (err error) + func (ru *RedisUtil) CacheWrapper(ctx context.Context, params *WrapperParams) (err error) + func (ru *RedisUtil) CacheWrapperMget(ctx context.Context, params *WrapperParamsMget) (err error) + func (ru *RedisUtil) Decr(ctx context.Context, key string) (res int64, err error) + func (ru *RedisUtil) DecrBy(ctx context.Context, key string, diff int64) (res int64, err error) + func (ru *RedisUtil) Del(ctx context.Context, key string) (err error) + func (ru *RedisUtil) Expire(ctx context.Context, key string, ttl int) (err error) + func (ru *RedisUtil) Get(ctx context.Context, key string, value interface{}) (hit bool, err error) + func (ru *RedisUtil) Incr(ctx context.Context, key string) (res int64, err error) + func (ru *RedisUtil) IncrBy(ctx context.Context, key string, diff int64) (res int64, err error) + func (ru *RedisUtil) MGet(ctx context.Context, keys []string, valuesInter interface{}) (hits []bool, err error) + func (ru *RedisUtil) Set(ctx context.Context, key string, value interface{}, ttl int) (err error) + func (ru *RedisUtil) TTL(ctx context.Context, key string) (ttl int, err error) + func (ru *RedisUtil) WrapDo(ctx context.Context, doFunction func(con redis.Conn) error) error + func (ru *RedisUtil) ZAdd(ctx context.Context, key string, infos []*SortSetInfo) (err error) + func (ru *RedisUtil) ZCard(ctx context.Context, key string) (res int64, err error) + func (ru *RedisUtil) ZRange(ctx context.Context, key string, start, end int) (result []string, err error) + func (ru *RedisUtil) ZRem(ctx context.Context, key string, names []string) (err error) + func (ru *RedisUtil) ZRevRange(ctx context.Context, key string, start, end int) (result []string, err error) + type SortSetInfo struct + Name string + Score int64 + type WrapperParams struct + ExpireSeconds int + FallbackFunc FallbackFunc + FlushCache bool + Key string + Result interface{} + SingleFlight bool + type WrapperParamsMget struct + BatchFallbackFunc MgetBatchFallbackFunc + ExpireSeconds []int + FallbackFuncSlice []MgetFallbackFunc + FlushCache bool + Keys []string + ResultSlice interface{} + SingleFlight bool