Versions in this module Expand all Collapse all v1 v1.6.0 Nov 2, 2023 v1.1.1 Nov 6, 2023 v1.1.0 Nov 6, 2023 Changes in this version + const ClusterType + const Nil + const NodeType + var ErrEmptyHost = errors.New("empty redis host") + var ErrEmptyKey = errors.New("empty redis key") + var ErrEmptyType = errors.New("empty redis type") + var ErrNilNode = errors.New("nil redis node") + func SetSlowThreshold(threshold time.Duration) + type ClosableNode interface + Close func() + func CreateBlockingNode(r *Redis) (ClosableNode, error) + type FloatCmd = red.FloatCmd + type FloatPair struct + Key string + Score float64 + type GeoLocation = red.GeoLocation + type GeoPos = red.GeoPos + type GeoRadiusQuery = red.GeoRadiusQuery + type IntCmd = red.IntCmd + type Map map[string]string + type Option func(r *Redis) + func Cluster() Option + func WithPass(pass string) Option + func WithTLS() Option + type Pair struct + Key string + Score int64 + type Pipeliner = red.Pipeliner + type Redis struct + Addr string + Pass string + Type string + func MustNewRedis(conf RedisConf, opts ...Option) *Redis + func New(addr string, opts ...Option) *Redis + func NewRedis(conf RedisConf, opts ...Option) (*Redis, error) + func (s *Redis) BitCount(key string, start, end int64) (int64, error) + func (s *Redis) BitCountCtx(ctx context.Context, key string, start, end int64) (val int64, err error) + func (s *Redis) BitOpAnd(destKey string, keys ...string) (int64, error) + func (s *Redis) BitOpAndCtx(ctx context.Context, destKey string, keys ...string) (val int64, err error) + func (s *Redis) BitOpNot(destKey, key string) (int64, error) + func (s *Redis) BitOpNotCtx(ctx context.Context, destKey, key string) (val int64, err error) + func (s *Redis) BitOpOr(destKey string, keys ...string) (int64, error) + func (s *Redis) BitOpOrCtx(ctx context.Context, destKey string, keys ...string) (val int64, err error) + func (s *Redis) BitOpXor(destKey string, keys ...string) (int64, error) + func (s *Redis) BitOpXorCtx(ctx context.Context, destKey string, keys ...string) (val int64, err error) + func (s *Redis) BitPos(key string, bit, start, end int64) (int64, error) + func (s *Redis) BitPosCtx(ctx context.Context, key string, bit, start, end int64) (val int64, err error) + func (s *Redis) Blpop(node RedisNode, key string) (string, error) + func (s *Redis) BlpopCtx(ctx context.Context, node RedisNode, key string) (string, error) + func (s *Redis) BlpopEx(node RedisNode, key string) (string, bool, error) + func (s *Redis) BlpopExCtx(ctx context.Context, node RedisNode, key string) (string, bool, error) + func (s *Redis) BlpopWithTimeout(node RedisNode, timeout time.Duration, key string) (string, error) + func (s *Redis) BlpopWithTimeoutCtx(ctx context.Context, node RedisNode, timeout time.Duration, key string) (string, error) + func (s *Redis) Decr(key string) (int64, error) + func (s *Redis) DecrCtx(ctx context.Context, key string) (val int64, err error) + func (s *Redis) Decrby(key string, decrement int64) (int64, error) + func (s *Redis) DecrbyCtx(ctx context.Context, key string, decrement int64) (val int64, err error) + func (s *Redis) Del(keys ...string) (int, error) + func (s *Redis) DelCtx(ctx context.Context, keys ...string) (val int, err error) + func (s *Redis) Eval(script string, keys []string, args ...any) (any, error) + func (s *Redis) EvalCtx(ctx context.Context, script string, keys []string, args ...any) (val any, err error) + func (s *Redis) EvalSha(sha string, keys []string, args ...any) (any, error) + func (s *Redis) EvalShaCtx(ctx context.Context, sha string, keys []string, args ...any) (val any, err error) + func (s *Redis) Exists(key string) (bool, error) + func (s *Redis) ExistsCtx(ctx context.Context, key string) (val bool, err error) + func (s *Redis) Expire(key string, seconds int) error + func (s *Redis) ExpireCtx(ctx context.Context, key string, seconds int) error + func (s *Redis) Expireat(key string, expireTime int64) error + func (s *Redis) ExpireatCtx(ctx context.Context, key string, expireTime int64) error + func (s *Redis) GeoAdd(key string, geoLocation ...*GeoLocation) (int64, error) + func (s *Redis) GeoAddCtx(ctx context.Context, key string, geoLocation ...*GeoLocation) (val int64, err error) + func (s *Redis) GeoDist(key, member1, member2, unit string) (float64, error) + func (s *Redis) GeoDistCtx(ctx context.Context, key, member1, member2, unit string) (val float64, err error) + func (s *Redis) GeoHash(key string, members ...string) ([]string, error) + func (s *Redis) GeoHashCtx(ctx context.Context, key string, members ...string) (val []string, err error) + func (s *Redis) GeoPos(key string, members ...string) ([]*GeoPos, error) + func (s *Redis) GeoPosCtx(ctx context.Context, key string, members ...string) (val []*GeoPos, err error) + func (s *Redis) GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) ([]GeoLocation, error) + func (s *Redis) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) ([]GeoLocation, error) + func (s *Redis) GeoRadiusByMemberCtx(ctx context.Context, key, member string, query *GeoRadiusQuery) (val []GeoLocation, err error) + func (s *Redis) GeoRadiusCtx(ctx context.Context, key string, longitude, latitude float64, ...) (val []GeoLocation, err error) + func (s *Redis) Get(key string) (string, error) + func (s *Redis) GetBit(key string, offset int64) (int, error) + func (s *Redis) GetBitCtx(ctx context.Context, key string, offset int64) (val int, err error) + func (s *Redis) GetCtx(ctx context.Context, key string) (val string, err error) + func (s *Redis) GetSet(key, value string) (string, error) + func (s *Redis) GetSetCtx(ctx context.Context, key, value string) (val string, err error) + func (s *Redis) Hdel(key string, fields ...string) (bool, error) + func (s *Redis) HdelCtx(ctx context.Context, key string, fields ...string) (val bool, err error) + func (s *Redis) Hexists(key, field string) (bool, error) + func (s *Redis) HexistsCtx(ctx context.Context, key, field string) (val bool, err error) + func (s *Redis) Hget(key, field string) (string, error) + func (s *Redis) HgetCtx(ctx context.Context, key, field string) (val string, err error) + func (s *Redis) Hgetall(key string) (map[string]string, error) + func (s *Redis) HgetallCtx(ctx context.Context, key string) (val map[string]string, err error) + func (s *Redis) Hincrby(key, field string, increment int) (int, error) + func (s *Redis) HincrbyCtx(ctx context.Context, key, field string, increment int) (val int, err error) + func (s *Redis) HincrbyFloat(key, field string, increment float64) (float64, error) + func (s *Redis) HincrbyFloatCtx(ctx context.Context, key, field string, increment float64) (val float64, err error) + func (s *Redis) Hkeys(key string) ([]string, error) + func (s *Redis) HkeysCtx(ctx context.Context, key string) (val []string, err error) + func (s *Redis) Hlen(key string) (int, error) + func (s *Redis) HlenCtx(ctx context.Context, key string) (val int, err error) + func (s *Redis) Hmget(key string, fields ...string) ([]string, error) + func (s *Redis) HmgetCtx(ctx context.Context, key string, fields ...string) (val []string, err error) + func (s *Redis) Hmset(key string, fieldsAndValues map[string]string) error + func (s *Redis) HmsetCtx(ctx context.Context, key string, fieldsAndValues map[string]string) error + func (s *Redis) Hscan(key string, cursor uint64, match string, count int64) (keys []string, cur uint64, err error) + func (s *Redis) HscanCtx(ctx context.Context, key string, cursor uint64, match string, count int64) (keys []string, cur uint64, err error) + func (s *Redis) Hset(key, field, value string) error + func (s *Redis) HsetCtx(ctx context.Context, key, field, value string) error + func (s *Redis) Hsetnx(key, field, value string) (bool, error) + func (s *Redis) HsetnxCtx(ctx context.Context, key, field, value string) (val bool, err error) + func (s *Redis) Hvals(key string) ([]string, error) + func (s *Redis) HvalsCtx(ctx context.Context, key string) (val []string, err error) + func (s *Redis) Incr(key string) (int64, error) + func (s *Redis) IncrCtx(ctx context.Context, key string) (val int64, err error) + func (s *Redis) Incrby(key string, increment int64) (int64, error) + func (s *Redis) IncrbyCtx(ctx context.Context, key string, increment int64) (val int64, err error) + func (s *Redis) IncrbyFloat(key string, increment float64) (float64, error) + func (s *Redis) IncrbyFloatCtx(ctx context.Context, key string, increment float64) (val float64, err error) + func (s *Redis) Keys(pattern string) ([]string, error) + func (s *Redis) KeysCtx(ctx context.Context, pattern string) (val []string, err error) + func (s *Redis) Lindex(key string, index int64) (string, error) + func (s *Redis) LindexCtx(ctx context.Context, key string, index int64) (val string, err error) + func (s *Redis) Llen(key string) (int, error) + func (s *Redis) LlenCtx(ctx context.Context, key string) (val int, err error) + func (s *Redis) Lpop(key string) (string, error) + func (s *Redis) LpopCount(key string, count int) ([]string, error) + func (s *Redis) LpopCountCtx(ctx context.Context, key string, count int) (val []string, err error) + func (s *Redis) LpopCtx(ctx context.Context, key string) (val string, err error) + func (s *Redis) Lpush(key string, values ...any) (int, error) + func (s *Redis) LpushCtx(ctx context.Context, key string, values ...any) (val int, err error) + func (s *Redis) Lrange(key string, start, stop int) ([]string, error) + func (s *Redis) LrangeCtx(ctx context.Context, key string, start, stop int) (val []string, err error) + func (s *Redis) Lrem(key string, count int, value string) (int, error) + func (s *Redis) LremCtx(ctx context.Context, key string, count int, value string) (val int, err error) + func (s *Redis) Ltrim(key string, start, stop int64) error + func (s *Redis) LtrimCtx(ctx context.Context, key string, start, stop int64) error + func (s *Redis) Mget(keys ...string) ([]string, error) + func (s *Redis) MgetCtx(ctx context.Context, keys ...string) (val []string, err error) + func (s *Redis) Persist(key string) (bool, error) + func (s *Redis) PersistCtx(ctx context.Context, key string) (val bool, err error) + func (s *Redis) Pfadd(key string, values ...any) (bool, error) + func (s *Redis) PfaddCtx(ctx context.Context, key string, values ...any) (val bool, err error) + func (s *Redis) Pfcount(key string) (int64, error) + func (s *Redis) PfcountCtx(ctx context.Context, key string) (val int64, err error) + func (s *Redis) Pfmerge(dest string, keys ...string) error + func (s *Redis) PfmergeCtx(ctx context.Context, dest string, keys ...string) error + func (s *Redis) Ping() bool + func (s *Redis) PingCtx(ctx context.Context) (val bool) + func (s *Redis) Pipelined(fn func(Pipeliner) error) error + func (s *Redis) PipelinedCtx(ctx context.Context, fn func(Pipeliner) error) error + func (s *Redis) Rpop(key string) (string, error) + func (s *Redis) RpopCount(key string, count int) ([]string, error) + func (s *Redis) RpopCountCtx(ctx context.Context, key string, count int) (val []string, err error) + func (s *Redis) RpopCtx(ctx context.Context, key string) (val string, err error) + func (s *Redis) Rpush(key string, values ...any) (int, error) + func (s *Redis) RpushCtx(ctx context.Context, key string, values ...any) (val int, err error) + func (s *Redis) Sadd(key string, values ...any) (int, error) + func (s *Redis) SaddCtx(ctx context.Context, key string, values ...any) (val int, err error) + func (s *Redis) Scan(cursor uint64, match string, count int64) (keys []string, cur uint64, err error) + func (s *Redis) ScanCtx(ctx context.Context, cursor uint64, match string, count int64) (keys []string, cur uint64, err error) + func (s *Redis) Scard(key string) (int64, error) + func (s *Redis) ScardCtx(ctx context.Context, key string) (val int64, err error) + func (s *Redis) ScriptLoad(script string) (string, error) + func (s *Redis) ScriptLoadCtx(ctx context.Context, script string) (string, error) + func (s *Redis) ScriptRun(script *Script, keys []string, args ...any) (any, error) + func (s *Redis) ScriptRunCtx(ctx context.Context, script *Script, keys []string, args ...any) (val any, err error) + func (s *Redis) Sdiff(keys ...string) ([]string, error) + func (s *Redis) SdiffCtx(ctx context.Context, keys ...string) (val []string, err error) + func (s *Redis) Sdiffstore(destination string, keys ...string) (int, error) + func (s *Redis) SdiffstoreCtx(ctx context.Context, destination string, keys ...string) (val int, err error) + func (s *Redis) Set(key, value string) error + func (s *Redis) SetBit(key string, offset int64, value int) (int, error) + func (s *Redis) SetBitCtx(ctx context.Context, key string, offset int64, value int) (val int, err error) + func (s *Redis) SetCtx(ctx context.Context, key, value string) error + func (s *Redis) Setex(key, value string, seconds int) error + func (s *Redis) SetexCtx(ctx context.Context, key, value string, seconds int) error + func (s *Redis) Setnx(key, value string) (bool, error) + func (s *Redis) SetnxCtx(ctx context.Context, key, value string) (val bool, err error) + func (s *Redis) SetnxEx(key, value string, seconds int) (bool, error) + func (s *Redis) SetnxExCtx(ctx context.Context, key, value string, seconds int) (val bool, err error) + func (s *Redis) Sinter(keys ...string) ([]string, error) + func (s *Redis) SinterCtx(ctx context.Context, keys ...string) (val []string, err error) + func (s *Redis) Sinterstore(destination string, keys ...string) (int, error) + func (s *Redis) SinterstoreCtx(ctx context.Context, destination string, keys ...string) (val int, err error) + func (s *Redis) Sismember(key string, value any) (bool, error) + func (s *Redis) SismemberCtx(ctx context.Context, key string, value any) (val bool, err error) + func (s *Redis) Smembers(key string) ([]string, error) + func (s *Redis) SmembersCtx(ctx context.Context, key string) (val []string, err error) + func (s *Redis) Spop(key string) (string, error) + func (s *Redis) SpopCtx(ctx context.Context, key string) (val string, err error) + func (s *Redis) Srandmember(key string, count int) ([]string, error) + func (s *Redis) SrandmemberCtx(ctx context.Context, key string, count int) (val []string, err error) + func (s *Redis) Srem(key string, values ...any) (int, error) + func (s *Redis) SremCtx(ctx context.Context, key string, values ...any) (val int, err error) + func (s *Redis) Sscan(key string, cursor uint64, match string, count int64) (keys []string, cur uint64, err error) + func (s *Redis) SscanCtx(ctx context.Context, key string, cursor uint64, match string, count int64) (keys []string, cur uint64, err error) + func (s *Redis) String() string + func (s *Redis) Sunion(keys ...string) ([]string, error) + func (s *Redis) SunionCtx(ctx context.Context, keys ...string) (val []string, err error) + func (s *Redis) Sunionstore(destination string, keys ...string) (int, error) + func (s *Redis) SunionstoreCtx(ctx context.Context, destination string, keys ...string) (val int, err error) + func (s *Redis) Ttl(key string) (int, error) + func (s *Redis) TtlCtx(ctx context.Context, key string) (val int, err error) + func (s *Redis) ZRevRangeWithScores(key string, start, stop int64) ([]Pair, error) + func (s *Redis) ZRevRangeWithScoresByFloat(key string, start, stop int64) ([]FloatPair, error) + func (s *Redis) ZRevRangeWithScoresByFloatCtx(ctx context.Context, key string, start, stop int64) (val []FloatPair, err error) + func (s *Redis) ZRevRangeWithScoresCtx(ctx context.Context, key string, start, stop int64) (val []Pair, err error) + func (s *Redis) Zadd(key string, score int64, value string) (bool, error) + func (s *Redis) ZaddCtx(ctx context.Context, key string, score int64, value string) (val bool, err error) + func (s *Redis) ZaddFloat(key string, score float64, value string) (bool, error) + func (s *Redis) ZaddFloatCtx(ctx context.Context, key string, score float64, value string) (val bool, err error) + func (s *Redis) Zadds(key string, ps ...Pair) (int64, error) + func (s *Redis) ZaddsCtx(ctx context.Context, key string, ps ...Pair) (val int64, err error) + func (s *Redis) Zcard(key string) (int, error) + func (s *Redis) ZcardCtx(ctx context.Context, key string) (val int, err error) + func (s *Redis) Zcount(key string, start, stop int64) (int, error) + func (s *Redis) ZcountCtx(ctx context.Context, key string, start, stop int64) (val int, err error) + func (s *Redis) Zincrby(key string, increment int64, field string) (int64, error) + func (s *Redis) ZincrbyCtx(ctx context.Context, key string, increment int64, field string) (val int64, err error) + func (s *Redis) Zrange(key string, start, stop int64) ([]string, error) + func (s *Redis) ZrangeCtx(ctx context.Context, key string, start, stop int64) (val []string, err error) + func (s *Redis) ZrangeWithScores(key string, start, stop int64) ([]Pair, error) + func (s *Redis) ZrangeWithScoresByFloat(key string, start, stop int64) ([]FloatPair, error) + func (s *Redis) ZrangeWithScoresByFloatCtx(ctx context.Context, key string, start, stop int64) (val []FloatPair, err error) + func (s *Redis) ZrangeWithScoresCtx(ctx context.Context, key string, start, stop int64) (val []Pair, err error) + func (s *Redis) ZrangebyscoreWithScores(key string, start, stop int64) ([]Pair, error) + func (s *Redis) ZrangebyscoreWithScoresAndLimit(key string, start, stop int64, page, size int) ([]Pair, error) + func (s *Redis) ZrangebyscoreWithScoresAndLimitCtx(ctx context.Context, key string, start, stop int64, page, size int) (val []Pair, err error) + func (s *Redis) ZrangebyscoreWithScoresByFloat(key string, start, stop float64) ([]FloatPair, error) + func (s *Redis) ZrangebyscoreWithScoresByFloatAndLimit(key string, start, stop float64, page, size int) ([]FloatPair, error) + func (s *Redis) ZrangebyscoreWithScoresByFloatAndLimitCtx(ctx context.Context, key string, start, stop float64, page, size int) (val []FloatPair, err error) + func (s *Redis) ZrangebyscoreWithScoresByFloatCtx(ctx context.Context, key string, start, stop float64) (val []FloatPair, err error) + func (s *Redis) ZrangebyscoreWithScoresCtx(ctx context.Context, key string, start, stop int64) (val []Pair, err error) + func (s *Redis) Zrank(key, field string) (int64, error) + func (s *Redis) ZrankCtx(ctx context.Context, key, field string) (val int64, err error) + func (s *Redis) Zrem(key string, values ...any) (int, error) + func (s *Redis) ZremCtx(ctx context.Context, key string, values ...any) (val int, err error) + func (s *Redis) Zremrangebyrank(key string, start, stop int64) (int, error) + func (s *Redis) ZremrangebyrankCtx(ctx context.Context, key string, start, stop int64) (val int, err error) + func (s *Redis) Zremrangebyscore(key string, start, stop int64) (int, error) + func (s *Redis) ZremrangebyscoreCtx(ctx context.Context, key string, start, stop int64) (val int, err error) + func (s *Redis) Zrevrange(key string, start, stop int64) ([]string, error) + func (s *Redis) ZrevrangeCtx(ctx context.Context, key string, start, stop int64) (val []string, err error) + func (s *Redis) ZrevrangeWithScores(key string, start, stop int64) ([]Pair, error) + func (s *Redis) ZrevrangeWithScoresByFloat(key string, start, stop int64) ([]FloatPair, error) + func (s *Redis) ZrevrangeWithScoresByFloatCtx(ctx context.Context, key string, start, stop int64) (val []FloatPair, err error) + func (s *Redis) ZrevrangeWithScoresCtx(ctx context.Context, key string, start, stop int64) (val []Pair, err error) + func (s *Redis) ZrevrangebyscoreWithScores(key string, start, stop int64) ([]Pair, error) + func (s *Redis) ZrevrangebyscoreWithScoresAndLimit(key string, start, stop int64, page, size int) ([]Pair, error) + func (s *Redis) ZrevrangebyscoreWithScoresAndLimitCtx(ctx context.Context, key string, start, stop int64, page, size int) (val []Pair, err error) + func (s *Redis) ZrevrangebyscoreWithScoresByFloat(key string, start, stop float64) ([]FloatPair, error) + func (s *Redis) ZrevrangebyscoreWithScoresByFloatAndLimit(key string, start, stop float64, page, size int) ([]FloatPair, error) + func (s *Redis) ZrevrangebyscoreWithScoresByFloatAndLimitCtx(ctx context.Context, key string, start, stop float64, page, size int) (val []FloatPair, err error) + func (s *Redis) ZrevrangebyscoreWithScoresByFloatCtx(ctx context.Context, key string, start, stop float64) (val []FloatPair, err error) + func (s *Redis) ZrevrangebyscoreWithScoresCtx(ctx context.Context, key string, start, stop int64) (val []Pair, err error) + func (s *Redis) Zrevrank(key, field string) (int64, error) + func (s *Redis) ZrevrankCtx(ctx context.Context, key, field string) (val int64, err error) + func (s *Redis) Zscan(key string, cursor uint64, match string, count int64) (keys []string, cur uint64, err error) + func (s *Redis) ZscanCtx(ctx context.Context, key string, cursor uint64, match string, count int64) (keys []string, cur uint64, err error) + func (s *Redis) Zscore(key, value string) (int64, error) + func (s *Redis) ZscoreByFloat(key, value string) (float64, error) + func (s *Redis) ZscoreByFloatCtx(ctx context.Context, key, value string) (val float64, err error) + func (s *Redis) ZscoreCtx(ctx context.Context, key, value string) (val int64, err error) + func (s *Redis) Zunionstore(dest string, store *ZStore) (int64, error) + func (s *Redis) ZunionstoreCtx(ctx context.Context, dest string, store *ZStore) (val int64, err error) + type RedisConf struct + Host string + NonBlock bool + Pass string + PingTimeout time.Duration + Tls bool + Type string + func (rc RedisConf) NewRedis() *Redis + func (rc RedisConf) Validate() error + type RedisKeyConf struct + Key string + func (rkc RedisKeyConf) Validate() error + type RedisLock struct + func NewRedisLock(store *Redis, key string) *RedisLock + func (rl *RedisLock) Acquire() (bool, error) + func (rl *RedisLock) AcquireCtx(ctx context.Context) (bool, error) + func (rl *RedisLock) Release() (bool, error) + func (rl *RedisLock) ReleaseCtx(ctx context.Context) (bool, error) + func (rl *RedisLock) SetExpire(seconds int) + type RedisNode interface + type Script = red.Script + func NewScript(script string) *Script + type ScriptCache struct + func GetScriptCache() *ScriptCache + func (sc *ScriptCache) GetSha(script string) (string, bool) + func (sc *ScriptCache) SetSha(script, sha string) + type StringCmd = red.StringCmd + type Z = red.Z + type ZStore = red.ZStore