Documentation ¶
Index ¶
- Constants
- func SetConfiger(ctx context.Context, configerType constants.ConfigerType) error
- func WatchUpdate(ctx context.Context)
- type RedisExt
- func (m *RedisExt) Confirm(ctx context.Context, key string) error
- func (m *RedisExt) Decr(ctx context.Context, key string) (n int64, err error)
- func (m *RedisExt) DecrBy(ctx context.Context, key string, val int64) (n int64, err error)
- func (m *RedisExt) Del(ctx context.Context, key string) (n int64, err error)
- func (m *RedisExt) Eval(ctx context.Context, script *Script, keys []string, args ...interface{}) (r interface{}, err error)
- func (m *RedisExt) EvalSha(ctx context.Context, script *Script, keys []string, args ...interface{}) (r interface{}, err error)
- func (m *RedisExt) Exists(ctx context.Context, key string) (n int64, err error)
- func (m *RedisExt) Expire(ctx context.Context, key string, expiration time.Duration) (b bool, err error)
- func (m *RedisExt) Get(ctx context.Context, key string) (s string, err error)
- func (m *RedisExt) GetBit(ctx context.Context, key string, offset int64) (n int64, err error)
- func (m *RedisExt) HDel(ctx context.Context, key string, fields ...string) (n int64, err error)
- func (m *RedisExt) HExists(ctx context.Context, key string, field string) (b bool, err error)
- func (m *RedisExt) HGet(ctx context.Context, key string, field string) (s string, err error)
- func (m *RedisExt) HGetAll(ctx context.Context, key string) (sm map[string]string, err error)
- func (m *RedisExt) HIncrBy(ctx context.Context, key string, field string, incr int64) (n int64, err error)
- func (m *RedisExt) HIncrByFloat(ctx context.Context, key string, field string, incr float64) (f float64, err error)
- func (m *RedisExt) HKeys(ctx context.Context, key string) (ss []string, err error)
- func (m *RedisExt) HLen(ctx context.Context, key string) (n int64, err error)
- func (m *RedisExt) HMGet(ctx context.Context, key string, fields ...string) (vs []interface{}, err error)
- func (m *RedisExt) HMSet(ctx context.Context, key string, fields map[string]interface{}) (s string, err error)
- func (m *RedisExt) HSet(ctx context.Context, key string, field string, value interface{}) (b bool, err error)
- func (m *RedisExt) HSetNX(ctx context.Context, key string, field string, val interface{}) (b bool, err error)
- func (m *RedisExt) HVals(ctx context.Context, key string) (ss []string, err error)
- func (m *RedisExt) Incr(ctx context.Context, key string) (n int64, err error)
- func (m *RedisExt) IncrBy(ctx context.Context, key string, val int64) (n int64, err error)
- func (m *RedisExt) LIndex(ctx context.Context, key string, index int64) (element string, err error)
- func (m *RedisExt) LInsert(ctx context.Context, key, op string, pivot, value interface{}) (n int64, err error)
- func (m *RedisExt) LLen(ctx context.Context, key string) (n int64, err error)
- func (m *RedisExt) LPop(ctx context.Context, key string) (element string, err error)
- func (m *RedisExt) LPush(ctx context.Context, key string, values ...interface{}) (n int64, err error)
- func (m *RedisExt) LPushX(ctx context.Context, key string, value interface{}) (n int64, err error)
- func (m *RedisExt) LRange(ctx context.Context, key string, start, stop int64) (r []string, err error)
- func (m *RedisExt) LRem(ctx context.Context, key string, count int64, value interface{}) (n int64, err error)
- func (m *RedisExt) LSet(ctx context.Context, key string, index int64, value interface{}) (r string, err error)
- func (m *RedisExt) LTrim(ctx context.Context, key string, start, stop int64) (r string, err error)
- func (m *RedisExt) Lock(ctx context.Context, key string, value interface{}, expiration time.Duration) (bool, error)
- func (m *RedisExt) LockWithTimeout(ctx context.Context, key string, value interface{}, ...) (r bool, err error)
- func (m *RedisExt) MGet(ctx context.Context, keys ...string) (v []interface{}, err error)
- func (m *RedisExt) MSet(ctx context.Context, pairs ...interface{}) (s string, err error)
- func (m *RedisExt) RPop(ctx context.Context, key string) (element string, err error)
- func (m *RedisExt) RPush(ctx context.Context, key string, values ...interface{}) (n int64, err error)
- func (m *RedisExt) RPushX(ctx context.Context, key string, value interface{}) (n int64, err error)
- func (m *RedisExt) ScriptExists(ctx context.Context, script *Script) (r bool, err error)
- func (m *RedisExt) ScriptLoad(ctx context.Context, script *Script) (r string, err error)
- func (m *RedisExt) Set(ctx context.Context, key string, val interface{}, exp time.Duration) (s string, err error)
- func (m *RedisExt) SetBit(ctx context.Context, key string, offset int64, value int) (n int64, err error)
- func (m *RedisExt) SetNX(ctx context.Context, key string, val interface{}, exp time.Duration) (b bool, err error)
- func (m *RedisExt) TTL(ctx context.Context, key string) (d time.Duration, err error)
- func (m *RedisExt) TryAcquire(ctx context.Context, key string, expiration, timeout time.Duration) (canHandle bool, state string, err error)
- func (m *RedisExt) Unlock(ctx context.Context, key string, value interface{}) (bool, error)
- func (m *RedisExt) ZAdd(ctx context.Context, key string, members []Z) (n int64, err error)
- func (m *RedisExt) ZAddCh(ctx context.Context, key string, members []Z) (n int64, err error)
- func (m *RedisExt) ZAddNX(ctx context.Context, key string, members []Z) (n int64, err error)
- func (m *RedisExt) ZAddNXCh(ctx context.Context, key string, members []Z) (n int64, err error)
- func (m *RedisExt) ZAddXX(ctx context.Context, key string, members []Z) (n int64, err error)
- func (m *RedisExt) ZAddXXCh(ctx context.Context, key string, members []Z) (n int64, err error)
- func (m *RedisExt) ZCard(ctx context.Context, key string) (n int64, err error)
- func (m *RedisExt) ZCount(ctx context.Context, key, min, max string) (n int64, err error)
- func (m *RedisExt) ZIncr(ctx context.Context, key string, member Z) (f float64, err error)
- func (m *RedisExt) ZIncrBy(ctx context.Context, key string, increment float64, member string) (f float64, err error)
- func (m *RedisExt) ZIncrNX(ctx context.Context, key string, member Z) (f float64, err error)
- func (m *RedisExt) ZIncrXX(ctx context.Context, key string, member Z) (f float64, err error)
- func (m *RedisExt) ZRange(ctx context.Context, key string, start, stop int64) (ss []string, err error)
- func (m *RedisExt) ZRangeByLex(ctx context.Context, key string, by ZRangeBy) (ss []string, err error)
- func (m *RedisExt) ZRangeByScore(ctx context.Context, key string, by ZRangeBy) (ss []string, err error)
- func (m *RedisExt) ZRangeWithScores(ctx context.Context, key string, start, stop int64) (zs []Z, err error)
- func (m *RedisExt) ZRank(ctx context.Context, key string, member string) (n int64, err error)
- func (m *RedisExt) ZRem(ctx context.Context, key string, members []interface{}) (n int64, err error)
- func (m *RedisExt) ZRevRange(ctx context.Context, key string, start, stop int64) (ss []string, err error)
- func (m *RedisExt) ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) (zs []Z, err error)
- func (m *RedisExt) ZRevRank(ctx context.Context, key string, member string) (n int64, err error)
- func (m *RedisExt) ZScore(ctx context.Context, key string, member string) (f float64, err error)
- type Script
- type Z
- type ZRangeBy
Constants ¶
View Source
const ( InitState = "0" Doing = "1" Done = "99" )
Variables ¶
This section is empty.
Functions ¶
func SetConfiger ¶
func SetConfiger(ctx context.Context, configerType constants.ConfigerType) error
func WatchUpdate ¶
Types ¶
type RedisExt ¶
type RedisExt struct {
// contains filtered or unexported fields
}
func NewRedisExt ¶
func (*RedisExt) Eval ¶ added in v1.3.35
func (m *RedisExt) Eval(ctx context.Context, script *Script, keys []string, args ...interface{}) (r interface{}, err error)
Eval exec with script
func (*RedisExt) EvalSha ¶ added in v1.3.35
func (m *RedisExt) EvalSha(ctx context.Context, script *Script, keys []string, args ...interface{}) (r interface{}, err error)
EvalSha exec with script hash
func (*RedisExt) HIncrByFloat ¶
func (*RedisExt) HSet ¶
func (m *RedisExt) HSet(ctx context.Context, key string, field string, value interface{}) (b bool, err error)
hashes apis
func (*RedisExt) Lock ¶ added in v1.3.35
func (m *RedisExt) Lock(ctx context.Context, key string, value interface{}, expiration time.Duration) (bool, error)
Lock get a global lock identified by key, if failed, return quickly
func (*RedisExt) LockWithTimeout ¶ added in v1.3.35
func (m *RedisExt) LockWithTimeout(ctx context.Context, key string, value interface{}, expiration, timeout time.Duration) (r bool, err error)
LockWithTimeout will retry get lock in timeout every retryTimeGap
func (*RedisExt) ScriptExists ¶ added in v1.3.35
ScriptExists check if script exists in redis server
func (*RedisExt) ScriptLoad ¶ added in v1.3.35
ScriptLoad load script to redis server
func (*RedisExt) TryAcquire ¶ added in v1.3.35
func (m *RedisExt) TryAcquire(ctx context.Context, key string, expiration, timeout time.Duration) (canHandle bool, state string, err error)
TryAcquire 通过特殊的全局锁,保证以key为依据的业务操作是幂等的,可能的情况如下:
入口参数: @timeout: 业务操作的超时时间,比如: 2min @expiration: 业务记录过期时间,比如: 24h
返回参数: @canHandle: 是否可以继续执行该笔业务记录, @state: 该笔业务记录的状态,InitState:初始状态 Done: 处理完成 Doing:正在处理中 @err: 异常错误
特别说明: 可以继续执行该笔业务记录的情况有: 记录为初始状态或者记录为Doing状态,且超过了timeout这个执行时间
func (*RedisExt) ZRangeByLex ¶
func (*RedisExt) ZRangeByScore ¶
func (*RedisExt) ZRangeWithScores ¶
func (*RedisExt) ZRevRangeWithScores ¶
Click to show internal directories.
Click to hide internal directories.