Documentation ¶
Index ¶
- Constants
- Variables
- func Decode(b []byte, ptr interface{}) error
- func Encode(val interface{}) ([]byte, error)
- func SetDefaultLogger(newLogger Logger)
- type BatchSetParams
- type DefaultLogger
- type FallbackFunc
- type LogData
- type Logger
- type MgetBatchFallbackFunc
- type MgetFallbackFunc
- type Option
- type OptionFunc
- type 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
- type WrapperParams
- type WrapperParamsMget
Constants ¶
View Source
const ( DefaultSingleFlightGroupNum = 10 TTLNoExpire = -1 // 不过期 )
View Source
const ( LevelDebug = "DEBUG" LevelInfo = "INFO" LevelWarn = "WARN" LevelError = "ERROR" )
Variables ¶
View Source
var ErrInvalidNum = errors.New("Invalid num")
Functions ¶
func SetDefaultLogger ¶
func SetDefaultLogger(newLogger Logger)
Types ¶
type BatchSetParams ¶
type DefaultLogger ¶
type DefaultLogger struct{}
type FallbackFunc ¶
type FallbackFunc func() (interface{}, error)
type Logger ¶
type Logger interface { Errorf(ctx context.Context, format string, args ...interface{}) Infof(ctx context.Context, format string, args ...interface{}) }
func GetDefaultLogger ¶
func GetDefaultLogger() Logger
type MgetBatchFallbackFunc ¶
type MgetFallbackFunc ¶
type Option ¶
type Option interface {
Apply(*RedisUtil)
}
func OptionLogger ¶
type OptionFunc ¶
type OptionFunc func(cacheUtil *RedisUtil)
func (OptionFunc) Apply ¶
func (of OptionFunc) Apply(cacheUtil *RedisUtil)
type RedisUtil ¶
type RedisUtil struct {
// contains filtered or unexported fields
}
func (*RedisUtil) BatchSet ¶
func (ru *RedisUtil) BatchSet(ctx context.Context, params *BatchSetParams) (err error)
func (*RedisUtil) CacheWrapper ¶
func (ru *RedisUtil) CacheWrapper(ctx context.Context, params *WrapperParams) (err error)
func (*RedisUtil) CacheWrapperMget ¶
func (ru *RedisUtil) CacheWrapperMget(ctx context.Context, params *WrapperParamsMget) (err error)
多key 缓存获取wrapper mget
type SortSetInfo ¶
type WrapperParams ¶
type WrapperParams struct { Key string ExpireSeconds int Result interface{} // 结果 FallbackFunc FallbackFunc SingleFlight bool // 是否启动 singleflight FlushCache bool // 是否用SetFunc刷新缓存 }
type WrapperParamsMget ¶
type WrapperParamsMget struct { Keys []string ExpireSeconds []int ResultSlice interface{} // 结果 slice of your result // 批量或并发二选一 FallbackFuncSlice []MgetFallbackFunc // 并发获取 BatchFallbackFunc MgetBatchFallbackFunc // 批量获取 SingleFlight bool // 是否启动 singleflight FlushCache bool // 用SetFunc刷新缓存 }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
singleflight
Package singleflight provides a duplicate function call suppression mechanism.
|
Package singleflight provides a duplicate function call suppression mechanism. |
Click to show internal directories.
Click to hide internal directories.