Documentation ¶
Index ¶
- Constants
- Variables
- func SetSlowThreshold(threshold time.Duration)
- type ClosableNode
- type FloatCmd
- type FloatPair
- type GeoLocation
- type GeoPos
- type GeoRadiusQuery
- type IntCmd
- type Map
- type Option
- type Pair
- type Pipeliner
- type Redis
- 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) Client() *red.Client
- 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) (int64, error)
- func (s *Redis) DelCtx(ctx context.Context, keys ...string) (val int64, 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, expire time.Duration) error
- func (s *Redis) ExpireCtx(ctx context.Context, key string, expire time.Duration) 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) (int64, error)
- func (s *Redis) GetBitCtx(ctx context.Context, key string, offset int64) (val int64, err error)
- func (s *Redis) GetCtx(ctx context.Context, key string) (val string, err error)
- func (s *Redis) GetSet(key string, value interface{}) (string, error)
- func (s *Redis) GetSetCtx(ctx context.Context, key string, value interface{}) (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) (int64, error)
- func (s *Redis) HincrbyCtx(ctx context.Context, key, field string, increment int) (val int64, 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) (int64, error)
- func (s *Redis) HlenCtx(ctx context.Context, key string) (val int64, 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 string, value interface{}) error
- func (s *Redis) HsetCtx(ctx context.Context, key, field string, value interface{}) error
- func (s *Redis) Hsetnx(key, field string, value interface{}) (bool, error)
- func (s *Redis) HsetnxCtx(ctx context.Context, key, field string, value interface{}) (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) (int64, error)
- func (s *Redis) LlenCtx(ctx context.Context, key string) (val int64, 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) (int64, error)
- func (s *Redis) LpushCtx(ctx context.Context, key string, values ...any) (val int64, 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 interface{}) (int64, error)
- func (s *Redis) LremCtx(ctx context.Context, key string, count int, value interface{}) (val int64, 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) (int64, error)
- func (s *Redis) RpushCtx(ctx context.Context, key string, values ...any) (val int64, err error)
- func (s *Redis) Sadd(key string, values ...any) (int64, error)
- func (s *Redis) SaddCtx(ctx context.Context, key string, values ...any) (val int64, 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) (int64, error)
- func (s *Redis) SdiffstoreCtx(ctx context.Context, destination string, keys ...string) (val int64, err error)
- func (s *Redis) Set(key string, value interface{}) error
- func (s *Redis) SetBit(key string, offset int64, value int) (int64, error)
- func (s *Redis) SetBitCtx(ctx context.Context, key string, offset int64, value int) (val int64, err error)
- func (s *Redis) SetCtx(ctx context.Context, key string, value interface{}) error
- func (s *Redis) Setex(key string, value interface{}, seconds int) error
- func (s *Redis) SetexCtx(ctx context.Context, key string, value interface{}, seconds int) error
- func (s *Redis) Setnx(key string, value interface{}) (bool, error)
- func (s *Redis) SetnxCtx(ctx context.Context, key string, value interface{}) (val bool, err error)
- func (s *Redis) SetnxEx(key string, value interface{}, seconds int) (bool, error)
- func (s *Redis) SetnxExCtx(ctx context.Context, key string, value interface{}, 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) (int64, error)
- func (s *Redis) SinterstoreCtx(ctx context.Context, destination string, keys ...string) (val int64, 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) (int64, error)
- func (s *Redis) SremCtx(ctx context.Context, key string, values ...any) (val int64, 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) (int64, error)
- func (s *Redis) SunionstoreCtx(ctx context.Context, destination string, keys ...string) (val int64, err error)
- func (s *Redis) Ttl(key string) (time.Duration, error)
- func (s *Redis) TtlCtx(ctx context.Context, key string) (val time.Duration, err error)
- func (s *Redis) TxPipelined(fn func(Pipeliner) error) error
- func (s *Redis) TxPipelinedCtx(ctx context.Context, fn func(Pipeliner) error) 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 interface{}) (bool, error)
- func (s *Redis) ZaddCtx(ctx context.Context, key string, score int64, value interface{}) (val bool, err error)
- func (s *Redis) ZaddFloat(key string, score float64, value interface{}) (bool, error)
- func (s *Redis) ZaddFloatCtx(ctx context.Context, key string, score float64, value interface{}) (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) (int64, error)
- func (s *Redis) ZcardCtx(ctx context.Context, key string) (val int64, err error)
- func (s *Redis) Zcount(key string, start, stop int64) (int64, error)
- func (s *Redis) ZcountCtx(ctx context.Context, key string, start, stop int64) (val int64, 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) (int64, error)
- func (s *Redis) ZremCtx(ctx context.Context, key string, values ...any) (val int64, err error)
- func (s *Redis) Zremrangebyrank(key string, start, stop int64) (int64, error)
- func (s *Redis) ZremrangebyrankCtx(ctx context.Context, key string, start, stop int64) (val int64, err error)
- func (s *Redis) Zremrangebyscore(key string, start, stop int64) (int64, error)
- func (s *Redis) ZremrangebyscoreCtx(ctx context.Context, key string, start, stop int64) (val int64, 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 string, 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
- type RedisKeyConf
- type RedisLock
- type RedisNode
- type Script
- type ScriptCache
- type StringCmd
- type Z
- type ZStore
Constants ¶
const ( // ClusterType means redis cluster. ClusterType = "cluster" // NodeType means redis node. NodeType = "node" // Nil is an alias of redis.Nil. Nil = red.Nil )
Variables ¶
var ( // ErrEmptyHost is an error that indicates no redis host is set. ErrEmptyHost = errors.New("empty redis host") // ErrEmptyType is an error that indicates no redis type is set. ErrEmptyType = errors.New("empty redis type") // ErrEmptyKey is an error that indicates no redis key is set. ErrEmptyKey = errors.New("empty redis key") )
var ( // ErrNilNode is an error that indicates a nil redis node. ErrNilNode = errors.New("nil redis node") )
Functions ¶
func SetSlowThreshold ¶
SetSlowThreshold sets the slow threshold.
Types ¶
type ClosableNode ¶
type ClosableNode interface { RedisNode Close() }
ClosableNode interface represents a closable redis node.
func CreateBlockingNode ¶
func CreateBlockingNode(r *Redis) (ClosableNode, error)
CreateBlockingNode returns a ClosableNode.
type GeoLocation ¶
type GeoLocation = red.GeoLocation
GeoLocation is used with GeoAdd to add geospatial location.
type GeoRadiusQuery ¶
type GeoRadiusQuery = red.GeoRadiusQuery
GeoRadiusQuery is used with GeoRadius to query geospatial index.
type Option ¶
type Option func(r *Redis)
Option defines the method to customize a Redis.
type Redis ¶
type Redis struct { Addr string Type string Pass string DB int // Maximum number of retries before giving up. // Default is 3 retries; -1 (not 0) disables retries. MaxRetries int // Minimum number of idle connections which is useful when establishing // new connection is slow. default 8 MinIdleConns int // contains filtered or unexported fields }
Redis defines a redis node/cluster. It is thread-safe.
func MustNewRedis ¶
MustNewRedis returns a Redis with given options.
func New ¶
New returns a Redis with given options. Deprecated: use MustNewRedis or NewRedis instead.
func (*Redis) BitCountCtx ¶
func (s *Redis) BitCountCtx(ctx context.Context, key string, start, end int64) (val int64, err error)
BitCountCtx is redis bitcount command implementation.
func (*Redis) BitOpAndCtx ¶
func (s *Redis) BitOpAndCtx(ctx context.Context, destKey string, keys ...string) (val int64, err error)
BitOpAndCtx is redis bit operation (and) command implementation.
func (*Redis) BitOpNotCtx ¶
BitOpNotCtx is redis bit operation (not) command implementation.
func (*Redis) BitOpOrCtx ¶
func (s *Redis) BitOpOrCtx(ctx context.Context, destKey string, keys ...string) (val int64, err error)
BitOpOrCtx is redis bit operation (or) command implementation.
func (*Redis) BitOpXorCtx ¶
func (s *Redis) BitOpXorCtx(ctx context.Context, destKey string, keys ...string) (val int64, err error)
BitOpXorCtx is redis bit operation (xor) command implementation.
func (*Redis) BitPosCtx ¶
func (s *Redis) BitPosCtx(ctx context.Context, key string, bit, start, end int64) (val int64, err error)
BitPosCtx is redis bitpos command implementation.
func (*Redis) Blpop ¶
Blpop uses passed in redis connection to execute blocking queries. Doesn't benefit from pooling redis connections of blocking queries
func (*Redis) BlpopCtx ¶
BlpopCtx uses passed in redis connection to execute blocking queries. Doesn't benefit from pooling redis connections of blocking queries
func (*Redis) BlpopEx ¶
BlpopEx uses passed in redis connection to execute blpop command. The difference against Blpop is that this method returns a bool to indicate success.
func (*Redis) BlpopExCtx ¶
BlpopExCtx uses passed in redis connection to execute blpop command. The difference against Blpop is that this method returns a bool to indicate success.
func (*Redis) BlpopWithTimeout ¶
BlpopWithTimeout uses passed in redis connection to execute blpop command. Control blocking query timeout
func (*Redis) BlpopWithTimeoutCtx ¶
func (s *Redis) BlpopWithTimeoutCtx(ctx context.Context, node RedisNode, timeout time.Duration, key string) (string, error)
BlpopWithTimeoutCtx uses passed in redis connection to execute blpop command. Control blocking query timeout
func (*Redis) EvalCtx ¶
func (s *Redis) EvalCtx(ctx context.Context, script string, keys []string, args ...any) (val any, err error)
EvalCtx is the implementation of redis eval command.
func (*Redis) EvalShaCtx ¶
func (s *Redis) EvalShaCtx(ctx context.Context, sha string, keys []string, args ...any) (val any, err error)
EvalShaCtx is the implementation of redis evalsha command.
func (*Redis) ExpireatCtx ¶
ExpireatCtx is the implementation of redis expireat command.
func (*Redis) GeoAdd ¶
func (s *Redis) GeoAdd(key string, geoLocation ...*GeoLocation) (int64, error)
GeoAdd is the implementation of redis geoadd command.
func (*Redis) GeoAddCtx ¶
func (s *Redis) GeoAddCtx(ctx context.Context, key string, geoLocation ...*GeoLocation) ( val int64, err error)
GeoAddCtx is the implementation of redis geoadd command.
func (*Redis) GeoDistCtx ¶
func (s *Redis) GeoDistCtx(ctx context.Context, key, member1, member2, unit string) ( val float64, err error)
GeoDistCtx is the implementation of redis geodist command.
func (*Redis) GeoHashCtx ¶
func (s *Redis) GeoHashCtx(ctx context.Context, key string, members ...string) ( val []string, err error)
GeoHashCtx is the implementation of redis geohash command.
func (*Redis) GeoPosCtx ¶
func (s *Redis) GeoPosCtx(ctx context.Context, key string, members ...string) ( val []*GeoPos, err error)
GeoPosCtx is the implementation of redis geopos command.
func (*Redis) GeoRadius ¶
func (s *Redis) GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) ( []GeoLocation, error)
GeoRadius is the implementation of redis georadius command.
func (*Redis) GeoRadiusByMember ¶
func (s *Redis) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) ([]GeoLocation, error)
GeoRadiusByMember is the implementation of redis georadiusbymember command.
func (*Redis) GeoRadiusByMemberCtx ¶
func (s *Redis) GeoRadiusByMemberCtx(ctx context.Context, key, member string, query *GeoRadiusQuery) (val []GeoLocation, err error)
GeoRadiusByMemberCtx is the implementation of redis georadiusbymember command.
func (*Redis) GeoRadiusCtx ¶
func (s *Redis) GeoRadiusCtx(ctx context.Context, key string, longitude, latitude float64, query *GeoRadiusQuery) (val []GeoLocation, err error)
GeoRadiusCtx is the implementation of redis georadius command.
func (*Redis) GetSetCtx ¶
func (s *Redis) GetSetCtx(ctx context.Context, key string, value interface{}) (val string, err error)
GetSetCtx is the implementation of redis getset command.
func (*Redis) HexistsCtx ¶
HexistsCtx is the implementation of redis hexists command.
func (*Redis) HgetallCtx ¶
HgetallCtx is the implementation of redis hgetall command.
func (*Redis) HincrbyCtx ¶
func (s *Redis) HincrbyCtx(ctx context.Context, key, field string, increment int) (val int64, err error)
HincrbyCtx is the implementation of redis hincrby command.
func (*Redis) HincrbyFloat ¶
HincrbyFloat is the implementation of redis hincrbyfloat command.
func (*Redis) HincrbyFloatCtx ¶
func (s *Redis) HincrbyFloatCtx(ctx context.Context, key, field string, increment float64) (val float64, err error)
HincrbyFloatCtx is the implementation of redis hincrbyfloat command.
func (*Redis) HmgetCtx ¶
func (s *Redis) HmgetCtx(ctx context.Context, key string, fields ...string) (val []string, err error)
HmgetCtx is the implementation of redis hmget command.
func (*Redis) Hscan ¶
func (s *Redis) Hscan(key string, cursor uint64, match string, count int64) ( keys []string, cur uint64, err error)
Hscan is the implementation of redis hscan command.
func (*Redis) HscanCtx ¶
func (s *Redis) HscanCtx(ctx context.Context, key string, cursor uint64, match string, count int64) ( keys []string, cur uint64, err error)
HscanCtx is the implementation of redis hscan command.
func (*Redis) HsetnxCtx ¶
func (s *Redis) HsetnxCtx(ctx context.Context, key, field string, value interface{}) (val bool, err error)
HsetnxCtx is the implementation of redis hsetnx command.
func (*Redis) IncrbyFloat ¶
IncrbyFloat is the implementation of redis hincrbyfloat command.
func (*Redis) IncrbyFloatCtx ¶
func (s *Redis) IncrbyFloatCtx(ctx context.Context, key string, increment float64) (val float64, err error)
IncrbyFloatCtx is the implementation of redis hincrbyfloat command.
func (*Redis) LpopCountCtx ¶
LpopCountCtx is the implementation of redis lpopCount command.
func (*Redis) LrangeCtx ¶
func (s *Redis) LrangeCtx(ctx context.Context, key string, start, stop int) (val []string, err error)
LrangeCtx is the implementation of redis lrange command.
func (*Redis) LremCtx ¶
func (s *Redis) LremCtx(ctx context.Context, key string, count int, value interface{}) (val int64, err error)
LremCtx is the implementation of redis lrem command.
func (*Redis) PersistCtx ¶
PersistCtx is the implementation of redis persist command.
func (*Redis) PfcountCtx ¶
PfcountCtx is the implementation of redis pfcount command.
func (*Redis) PfmergeCtx ¶
PfmergeCtx is the implementation of redis pfmerge command.
func (*Redis) PipelinedCtx ¶
PipelinedCtx lets fn execute pipelined commands. Results need to be retrieved by calling Pipeline.Exec()
func (*Redis) RpopCountCtx ¶
RpopCountCtx is the implementation of redis rpopCount command.
func (*Redis) Scan ¶
func (s *Redis) Scan(cursor uint64, match string, count int64) (keys []string, cur uint64, err error)
Scan is the implementation of redis scan command.
func (*Redis) ScanCtx ¶
func (s *Redis) ScanCtx(ctx context.Context, cursor uint64, match string, count int64) ( keys []string, cur uint64, err error)
ScanCtx is the implementation of redis scan command.
func (*Redis) ScriptLoad ¶
ScriptLoad is the implementation of redis script load command.
func (*Redis) ScriptLoadCtx ¶
ScriptLoadCtx is the implementation of redis script load command.
func (*Redis) ScriptRunCtx ¶
func (s *Redis) ScriptRunCtx(ctx context.Context, script *Script, keys []string, args ...any) (val any, err error)
ScriptRunCtx is the implementation of *redis.Script run command.
func (*Redis) Sdiffstore ¶
Sdiffstore is the implementation of redis sdiffstore command.
func (*Redis) SdiffstoreCtx ¶
func (s *Redis) SdiffstoreCtx(ctx context.Context, destination string, keys ...string) ( val int64, err error)
SdiffstoreCtx is the implementation of redis sdiffstore command.
func (*Redis) SetBitCtx ¶
func (s *Redis) SetBitCtx(ctx context.Context, key string, offset int64, value int) (val int64, err error)
SetBitCtx is the implementation of redis setbit command.
func (*Redis) SetnxExCtx ¶
func (s *Redis) SetnxExCtx(ctx context.Context, key string, value interface{}, seconds int) (val bool, err error)
SetnxExCtx is the implementation of redis setnx command with expire.
func (*Redis) Sinterstore ¶
Sinterstore is the implementation of redis sinterstore command.
func (*Redis) SinterstoreCtx ¶
func (s *Redis) SinterstoreCtx(ctx context.Context, destination string, keys ...string) ( val int64, err error)
SinterstoreCtx is the implementation of redis sinterstore command.
func (*Redis) SismemberCtx ¶
SismemberCtx is the implementation of redis sismember command.
func (*Redis) SmembersCtx ¶
SmembersCtx is the implementation of redis smembers command.
func (*Redis) Srandmember ¶
Srandmember is the implementation of redis srandmember command.
func (*Redis) SrandmemberCtx ¶
func (s *Redis) SrandmemberCtx(ctx context.Context, key string, count int) (val []string, err error)
SrandmemberCtx is the implementation of redis srandmember command.
func (*Redis) Sscan ¶
func (s *Redis) Sscan(key string, cursor uint64, match string, count int64) ( keys []string, cur uint64, err error)
Sscan is the implementation of redis sscan command.
func (*Redis) SscanCtx ¶
func (s *Redis) SscanCtx(ctx context.Context, key string, cursor uint64, match string, count int64) ( keys []string, cur uint64, err error)
SscanCtx is the implementation of redis sscan command.
func (*Redis) Sunionstore ¶
Sunionstore is the implementation of redis sunionstore command.
func (*Redis) SunionstoreCtx ¶
func (s *Redis) SunionstoreCtx(ctx context.Context, destination string, keys ...string) ( val int64, err error)
SunionstoreCtx is the implementation of redis sunionstore command.
func (*Redis) TxPipelined ¶
Pipelined lets fn execute pipelined commands.
func (*Redis) TxPipelinedCtx ¶
PipelinedCtx lets fn execute pipelined commands. Results need to be retrieved by calling Pipeline.Exec()
func (*Redis) ZRevRangeWithScores ¶
ZRevRangeWithScores is the implementation of redis zrevrange command with scores. Deprecated: use ZrevrangeWithScores instead.
func (*Redis) ZRevRangeWithScoresByFloat ¶
ZRevRangeWithScoresByFloat is the implementation of redis zrevrange command with scores by float. Deprecated: use ZrevrangeWithScoresByFloat instead.
func (*Redis) ZRevRangeWithScoresByFloatCtx ¶
func (s *Redis) ZRevRangeWithScoresByFloatCtx(ctx context.Context, key string, start, stop int64) ( val []FloatPair, err error)
ZRevRangeWithScoresByFloatCtx is the implementation of redis zrevrange command with scores by float. Deprecated: use ZrevrangeWithScoresByFloatCtx instead.
func (*Redis) ZRevRangeWithScoresCtx ¶
func (s *Redis) ZRevRangeWithScoresCtx(ctx context.Context, key string, start, stop int64) ( val []Pair, err error)
ZRevRangeWithScoresCtx is the implementation of redis zrevrange command with scores. Deprecated: use ZrevrangeWithScoresCtx instead.
func (*Redis) ZaddCtx ¶
func (s *Redis) ZaddCtx(ctx context.Context, key string, score int64, value interface{}) ( val bool, err error)
ZaddCtx is the implementation of redis zadd command.
func (*Redis) ZaddFloatCtx ¶
func (s *Redis) ZaddFloatCtx(ctx context.Context, key string, score float64, value interface{}) ( val bool, err error)
ZaddFloatCtx is the implementation of redis zadd command.
func (*Redis) ZcountCtx ¶
func (s *Redis) ZcountCtx(ctx context.Context, key string, start, stop int64) (val int64, err error)
ZcountCtx is the implementation of redis zcount command.
func (*Redis) ZincrbyCtx ¶
func (s *Redis) ZincrbyCtx(ctx context.Context, key string, increment int64, field string) ( val int64, err error)
ZincrbyCtx is the implementation of redis zincrby command.
func (*Redis) ZrangeCtx ¶
func (s *Redis) ZrangeCtx(ctx context.Context, key string, start, stop int64) ( val []string, err error)
ZrangeCtx is the implementation of redis zrange command.
func (*Redis) ZrangeWithScores ¶
ZrangeWithScores is the implementation of redis zrange command with scores.
func (*Redis) ZrangeWithScoresByFloat ¶
ZrangeWithScoresByFloat is the implementation of redis zrange command with scores by float64.
func (*Redis) ZrangeWithScoresByFloatCtx ¶
func (s *Redis) ZrangeWithScoresByFloatCtx(ctx context.Context, key string, start, stop int64) ( val []FloatPair, err error)
ZrangeWithScoresByFloatCtx is the implementation of redis zrange command with scores by float64.
func (*Redis) ZrangeWithScoresCtx ¶
func (s *Redis) ZrangeWithScoresCtx(ctx context.Context, key string, start, stop int64) ( val []Pair, err error)
ZrangeWithScoresCtx is the implementation of redis zrange command with scores.
func (*Redis) ZrangebyscoreWithScores ¶
ZrangebyscoreWithScores is the implementation of redis zrangebyscore command with scores.
func (*Redis) ZrangebyscoreWithScoresAndLimit ¶
func (s *Redis) ZrangebyscoreWithScoresAndLimit(key string, start, stop int64, page, size int) ([]Pair, error)
ZrangebyscoreWithScoresAndLimit is the implementation of redis zrangebyscore command with scores and limit.
func (*Redis) ZrangebyscoreWithScoresAndLimitCtx ¶
func (s *Redis) ZrangebyscoreWithScoresAndLimitCtx(ctx context.Context, key string, start, stop int64, page, size int) (val []Pair, err error)
ZrangebyscoreWithScoresAndLimitCtx is the implementation of redis zrangebyscore command with scores and limit.
func (*Redis) ZrangebyscoreWithScoresByFloat ¶
func (s *Redis) ZrangebyscoreWithScoresByFloat(key string, start, stop float64) ([]FloatPair, error)
ZrangebyscoreWithScoresByFloat is the implementation of redis zrangebyscore command with scores by float.
func (*Redis) ZrangebyscoreWithScoresByFloatAndLimit ¶
func (s *Redis) ZrangebyscoreWithScoresByFloatAndLimit(key string, start, stop float64, page, size int) ([]FloatPair, error)
ZrangebyscoreWithScoresByFloatAndLimit is the implementation of redis zrangebyscore command with scores by float and limit.
func (*Redis) ZrangebyscoreWithScoresByFloatAndLimitCtx ¶
func (s *Redis) ZrangebyscoreWithScoresByFloatAndLimitCtx(ctx context.Context, key string, start, stop float64, page, size int) (val []FloatPair, err error)
ZrangebyscoreWithScoresByFloatAndLimitCtx is the implementation of redis zrangebyscore command with scores by float and limit.
func (*Redis) ZrangebyscoreWithScoresByFloatCtx ¶
func (s *Redis) ZrangebyscoreWithScoresByFloatCtx(ctx context.Context, key string, start, stop float64) ( val []FloatPair, err error)
ZrangebyscoreWithScoresByFloatCtx is the implementation of redis zrangebyscore command with scores by float.
func (*Redis) ZrangebyscoreWithScoresCtx ¶
func (s *Redis) ZrangebyscoreWithScoresCtx(ctx context.Context, key string, start, stop int64) ( val []Pair, err error)
ZrangebyscoreWithScoresCtx is the implementation of redis zrangebyscore command with scores.
func (*Redis) Zremrangebyrank ¶
Zremrangebyrank is the implementation of redis zremrangebyrank command.
func (*Redis) ZremrangebyrankCtx ¶
func (s *Redis) ZremrangebyrankCtx(ctx context.Context, key string, start, stop int64) ( val int64, err error)
ZremrangebyrankCtx is the implementation of redis zremrangebyrank command.
func (*Redis) Zremrangebyscore ¶
Zremrangebyscore is the implementation of redis zremrangebyscore command.
func (*Redis) ZremrangebyscoreCtx ¶
func (s *Redis) ZremrangebyscoreCtx(ctx context.Context, key string, start, stop int64) ( val int64, err error)
ZremrangebyscoreCtx is the implementation of redis zremrangebyscore command.
func (*Redis) ZrevrangeCtx ¶
func (s *Redis) ZrevrangeCtx(ctx context.Context, key string, start, stop int64) ( val []string, err error)
ZrevrangeCtx is the implementation of redis zrevrange command.
func (*Redis) ZrevrangeWithScores ¶
ZrevrangeWithScores is the implementation of redis zrevrange command with scores.
func (*Redis) ZrevrangeWithScoresByFloat ¶
ZrevrangeWithScoresByFloat is the implementation of redis zrevrange command with scores by float.
func (*Redis) ZrevrangeWithScoresByFloatCtx ¶
func (s *Redis) ZrevrangeWithScoresByFloatCtx(ctx context.Context, key string, start, stop int64) ( val []FloatPair, err error)
ZrevrangeWithScoresByFloatCtx is the implementation of redis zrevrange command with scores by float.
func (*Redis) ZrevrangeWithScoresCtx ¶
func (s *Redis) ZrevrangeWithScoresCtx(ctx context.Context, key string, start, stop int64) ( val []Pair, err error)
ZrevrangeWithScoresCtx is the implementation of redis zrevrange command with scores.
func (*Redis) ZrevrangebyscoreWithScores ¶
ZrevrangebyscoreWithScores is the implementation of redis zrevrangebyscore command with scores.
func (*Redis) ZrevrangebyscoreWithScoresAndLimit ¶
func (s *Redis) ZrevrangebyscoreWithScoresAndLimit(key string, start, stop int64, page, size int) ([]Pair, error)
ZrevrangebyscoreWithScoresAndLimit is the implementation of redis zrevrangebyscore command with scores and limit.
func (*Redis) ZrevrangebyscoreWithScoresAndLimitCtx ¶
func (s *Redis) ZrevrangebyscoreWithScoresAndLimitCtx(ctx context.Context, key string, start, stop int64, page, size int) (val []Pair, err error)
ZrevrangebyscoreWithScoresAndLimitCtx is the implementation of redis zrevrangebyscore command with scores and limit.
func (*Redis) ZrevrangebyscoreWithScoresByFloat ¶
func (s *Redis) ZrevrangebyscoreWithScoresByFloat(key string, start, stop float64) ( []FloatPair, error)
ZrevrangebyscoreWithScoresByFloat is the implementation of redis zrevrangebyscore command with scores by float.
func (*Redis) ZrevrangebyscoreWithScoresByFloatAndLimit ¶
func (s *Redis) ZrevrangebyscoreWithScoresByFloatAndLimit(key string, start, stop float64, page, size int) ([]FloatPair, error)
ZrevrangebyscoreWithScoresByFloatAndLimit is the implementation of redis zrevrangebyscore command with scores by float and limit.
func (*Redis) ZrevrangebyscoreWithScoresByFloatAndLimitCtx ¶
func (s *Redis) ZrevrangebyscoreWithScoresByFloatAndLimitCtx(ctx context.Context, key string, start, stop float64, page, size int) (val []FloatPair, err error)
ZrevrangebyscoreWithScoresByFloatAndLimitCtx is the implementation of redis zrevrangebyscore command with scores by float and limit.
func (*Redis) ZrevrangebyscoreWithScoresByFloatCtx ¶
func (s *Redis) ZrevrangebyscoreWithScoresByFloatCtx(ctx context.Context, key string, start, stop float64) (val []FloatPair, err error)
ZrevrangebyscoreWithScoresByFloatCtx is the implementation of redis zrevrangebyscore command with scores by float.
func (*Redis) ZrevrangebyscoreWithScoresCtx ¶
func (s *Redis) ZrevrangebyscoreWithScoresCtx(ctx context.Context, key string, start, stop int64) ( val []Pair, err error)
ZrevrangebyscoreWithScoresCtx is the implementation of redis zrevrangebyscore command with scores.
func (*Redis) ZrevrankCtx ¶
ZrevrankCtx is the implementation of redis zrevrank command.
func (*Redis) Zscan ¶
func (s *Redis) Zscan(key string, cursor uint64, match string, count int64) ( keys []string, cur uint64, err error)
Zscan is the implementation of redis zscan command.
func (*Redis) ZscanCtx ¶
func (s *Redis) ZscanCtx(ctx context.Context, key string, cursor uint64, match string, count int64) ( keys []string, cur uint64, err error)
ZscanCtx is the implementation of redis zscan command.
func (*Redis) ZscoreByFloat ¶
ZscoreByFloat is the implementation of redis zscore command score by float.
func (*Redis) ZscoreByFloatCtx ¶
ZscoreByFloatCtx is the implementation of redis zscore command score by float.
func (*Redis) Zunionstore ¶
Zunionstore is the implementation of redis zunionstore command.
type RedisConf ¶
type RedisConf struct { Host string DB int //default database is 0. // Maximum number of retries before giving up. // Default is 3 retries; -1 (not 0) disables retries. MaxRetries int // Minimum number of idle connections which is useful when establishing // new connection is slow. default 8 MinIdleConns int Type string `json:",default=node,options=node|cluster"` Pass string `json:",optional"` Tls bool `json:",optional"` NonBlock bool `json:",default=true"` // PingTimeout is the timeout for ping redis. PingTimeout time.Duration `json:",default=1s"` }
A RedisConf is a redis config.
type RedisKeyConf ¶
A RedisKeyConf is a redis config with key.
func (RedisKeyConf) Validate ¶
func (rkc RedisKeyConf) Validate() error
Validate validates the RedisKeyConf.
type RedisLock ¶
type RedisLock struct {
// contains filtered or unexported fields
}
A RedisLock is a redis lock.
func NewRedisLock ¶
NewRedisLock returns a RedisLock.
func (*RedisLock) AcquireCtx ¶
AcquireCtx acquires the lock with the given ctx.
func (*RedisLock) ReleaseCtx ¶
ReleaseCtx releases the lock with the given ctx.
type ScriptCache ¶
A ScriptCache is a cache that stores a script with its sha key.
func (*ScriptCache) GetSha ¶
func (sc *ScriptCache) GetSha(script string) (string, bool)
GetSha returns the sha string of given script.
func (*ScriptCache) SetSha ¶
func (sc *ScriptCache) SetSha(script, sha string)
SetSha sets script with sha into the ScriptCache.