Documentation ¶
Index ¶
- Constants
- Variables
- func SetSlowThreshold(threshold time.Duration)
- type ClosableNode
- type FloatCmd
- 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) (val int64, err error)
- func (s *Redis) BitOpAnd(destKey string, keys ...string) (val int64, err error)
- func (s *Redis) BitOpNot(destKey, key string) (val int64, err error)
- func (s *Redis) BitOpOr(destKey string, keys ...string) (val int64, err error)
- func (s *Redis) BitOpXor(destKey string, keys ...string) (val int64, err error)
- func (s *Redis) BitPos(key string, bit, start, end int64) (val int64, err error)
- func (s *Redis) Blpop(redisNode RedisNode, key string) (string, error)
- func (s *Redis) BlpopEx(redisNode RedisNode, key string) (string, bool, error)
- func (s *Redis) Decr(key string) (val int64, err error)
- func (s *Redis) Decrby(key string, increment int64) (val int64, err error)
- func (s *Redis) Del(keys ...string) (val int, err error)
- func (s *Redis) Eval(script string, keys []string, args ...interface{}) (val interface{}, err error)
- func (s *Redis) EvalSha(sha string, keys []string, args ...interface{}) (val interface{}, err error)
- func (s *Redis) Exists(key string) (val bool, err error)
- func (s *Redis) Expire(key string, seconds int) error
- func (s *Redis) Expireat(key string, expireTime int64) error
- func (s *Redis) GeoAdd(key string, geoLocation ...*GeoLocation) (val int64, err error)
- func (s *Redis) GeoDist(key, member1, member2, unit string) (val float64, err error)
- func (s *Redis) GeoHash(key string, members ...string) (val []string, err error)
- func (s *Redis) GeoPos(key string, members ...string) (val []*GeoPos, err error)
- func (s *Redis) GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) (val []GeoLocation, err error)
- func (s *Redis) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) (val []GeoLocation, err error)
- func (s *Redis) Get(key string) (val string, err error)
- func (s *Redis) GetBit(key string, offset int64) (val int, err error)
- func (s *Redis) Hdel(key string, fields ...string) (val bool, err error)
- func (s *Redis) Hexists(key, field string) (val bool, err error)
- func (s *Redis) Hget(key, field string) (val string, err error)
- func (s *Redis) Hgetall(key string) (val map[string]string, err error)
- func (s *Redis) Hincrby(key, field string, increment int) (val int, err error)
- func (s *Redis) Hkeys(key string) (val []string, err error)
- func (s *Redis) Hlen(key string) (val int, err error)
- func (s *Redis) Hmget(key string, fields ...string) (val []string, err error)
- func (s *Redis) Hmset(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) Hset(key, field, value string) error
- func (s *Redis) Hsetnx(key, field, value string) (val bool, err error)
- func (s *Redis) Hvals(key string) (val []string, err error)
- func (s *Redis) Incr(key string) (val int64, err error)
- func (s *Redis) Incrby(key string, increment int64) (val int64, err error)
- func (s *Redis) Keys(pattern string) (val []string, err error)
- func (s *Redis) Lindex(key string, index int64) (val string, err error)
- func (s *Redis) Llen(key string) (val int, err error)
- func (s *Redis) Lpop(key string) (val string, err error)
- func (s *Redis) Lpush(key string, values ...interface{}) (val int, err error)
- func (s *Redis) Lrange(key string, start, stop int) (val []string, err error)
- func (s *Redis) Lrem(key string, count int, value string) (val int, err error)
- func (s *Redis) Ltrim(key string, start, stop int64) error
- func (s *Redis) Mget(keys ...string) (val []string, err error)
- func (s *Redis) Persist(key string) (val bool, err error)
- func (s *Redis) Pfadd(key string, values ...interface{}) (val bool, err error)
- func (s *Redis) Pfcount(key string) (val int64, err error)
- func (s *Redis) Pfmerge(dest string, keys ...string) error
- func (s *Redis) Ping() (val bool)
- func (s *Redis) Pipelined(fn func(Pipeliner) error) (err error)
- func (s *Redis) Rpop(key string) (val string, err error)
- func (s *Redis) Rpush(key string, values ...interface{}) (val int, err error)
- func (s *Redis) Sadd(key string, values ...interface{}) (val int, err error)
- func (s *Redis) Scan(cursor uint64, match string, count int64) (keys []string, cur uint64, err error)
- func (s *Redis) Scard(key string) (val int64, err error)
- func (s *Redis) ScriptLoad(script string) (string, error)
- func (s *Redis) Sdiff(keys ...string) (val []string, err error)
- func (s *Redis) Sdiffstore(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) error
- func (s *Redis) Setex(key, value string, seconds int) error
- func (s *Redis) Setnx(key, value string) (val bool, err error)
- func (s *Redis) SetnxEx(key, value string, seconds int) (val bool, err error)
- func (s *Redis) Sinter(keys ...string) (val []string, err error)
- func (s *Redis) Sinterstore(destination string, keys ...string) (val int, err error)
- func (s *Redis) Sismember(key string, value interface{}) (val bool, err error)
- func (s *Redis) Smembers(key string) (val []string, err error)
- func (s *Redis) Spop(key string) (val string, err error)
- func (s *Redis) Srandmember(key string, count int) (val []string, err error)
- func (s *Redis) Srem(key string, values ...interface{}) (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) String() string
- func (s *Redis) Sunion(keys ...string) (val []string, err error)
- func (s *Redis) Sunionstore(destination string, keys ...string) (val int, err error)
- func (s *Redis) Ttl(key string) (val int, err error)
- func (s *Redis) ZRevRangeWithScores(key string, start, stop int64) (val []Pair, err error)
- func (s *Redis) Zadd(key string, score int64, value string) (val bool, err error)
- func (s *Redis) Zadds(key string, ps ...Pair) (val int64, err error)
- func (s *Redis) Zcard(key string) (val int, err error)
- func (s *Redis) Zcount(key string, start, stop int64) (val int, err error)
- func (s *Redis) Zincrby(key string, increment int64, field string) (val int64, err error)
- func (s *Redis) Zrange(key string, start, stop int64) (val []string, err error)
- func (s *Redis) ZrangeWithScores(key string, start, stop int64) (val []Pair, err error)
- func (s *Redis) ZrangebyscoreWithScores(key string, start, stop int64) (val []Pair, err error)
- func (s *Redis) ZrangebyscoreWithScoresAndLimit(key string, start, stop int64, page, size int) (val []Pair, err error)
- func (s *Redis) Zrank(key, field string) (val int64, err error)
- func (s *Redis) Zrem(key string, values ...interface{}) (val int, err error)
- func (s *Redis) Zremrangebyrank(key string, start, stop int64) (val int, err error)
- func (s *Redis) Zremrangebyscore(key string, start, stop int64) (val int, err error)
- func (s *Redis) Zrevrange(key string, start, stop int64) (val []string, err error)
- func (s *Redis) ZrevrangebyscoreWithScores(key string, start, stop int64) (val []Pair, err error)
- func (s *Redis) ZrevrangebyscoreWithScoresAndLimit(key string, start, stop int64, page, size int) (val []Pair, err error)
- func (s *Redis) Zrevrank(key, field string) (val int64, err error)
- func (s *Redis) Zscore(key, value string) (val int64, err error)
- func (s *Redis) Zunionstore(dest string, store ZStore, keys ...string) (val int64, err error)
- type RedisConf
- type RedisKeyConf
- type RedisLock
- type RedisNode
- 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.
func WithPoolSize ¶
WithPoolSize customizes the given Redis with given PoolSize
func WithPoolTimeout ¶
WithPoolTimeout customizes the given Redis with given PoolTimeout
type Redis ¶
type Redis struct { Addr string Type string Pass string DB int PoolSize int PoolTimeout time.Duration // contains filtered or unexported fields }
Redis defines a redis node/cluster. It is thread-safe.
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) 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) Eval ¶
func (s *Redis) Eval(script string, keys []string, args ...interface{}) (val interface{}, err error)
Eval is the implementation of redis eval command.
func (*Redis) EvalSha ¶
func (s *Redis) EvalSha(sha string, keys []string, args ...interface{}) (val interface{}, err error)
EvalSha is the implementation of redis evalsha command.
func (*Redis) GeoAdd ¶
func (s *Redis) GeoAdd(key string, geoLocation ...*GeoLocation) (val int64, err error)
GeoAdd is the implementation of redis geoadd command.
func (*Redis) GeoRadius ¶
func (s *Redis) GeoRadius(key string, longitude, latitude float64, query *GeoRadiusQuery) (val []GeoLocation, err error)
GeoRadius is the implementation of redis georadius command.
func (*Redis) GeoRadiusByMember ¶
func (s *Redis) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) (val []GeoLocation, err error)
GeoRadiusByMember is the implementation of redis georadiusbymember 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) 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) ScriptLoad ¶
ScriptLoad is the implementation of redis script load command.
func (*Redis) Sdiffstore ¶
Sdiffstore is the implementation of redis sdiffstore command.
func (*Redis) Sinterstore ¶
Sinterstore is the implementation of redis sinterstore command.
func (*Redis) Srandmember ¶
Srandmember 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) Sunionstore ¶
Sunionstore is the implementation of redis sunionstore command.
func (*Redis) ZRevRangeWithScores ¶
ZRevRangeWithScores is the implementation of redis zrevrange command with scores.
func (*Redis) ZrangeWithScores ¶
ZrangeWithScores 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) ( val []Pair, err error)
ZrangebyscoreWithScoresAndLimit is the implementation of redis zrangebyscore command with scores and limit.
func (*Redis) Zremrangebyrank ¶
Zremrangebyrank is the implementation of redis zremrangebyrank command.
func (*Redis) Zremrangebyscore ¶
Zremrangebyscore is the implementation of redis zremrangebyscore command.
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) ( val []Pair, err error)
ZrevrangebyscoreWithScoresAndLimit is the implementation of redis zrevrangebyscore command with scores and limit.
type RedisConf ¶
type RedisConf struct { Host string Type string `json:",default=node,options=node|cluster"` Pass string `json:",optional"` Tls bool `json:",optional"` }
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.
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.