Documentation ¶
Index ¶
- Constants
- Variables
- 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) 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) 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) 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 = errors.New("nil redis node")
ErrNilNode is an error that indicates a nil redis node.
Functions ¶
This section is empty.
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 ¶ added in v1.0.28
type GeoLocation = red.GeoLocation
GeoLocation is used with GeoAdd to add geospatial location.
type GeoRadiusQuery ¶ added in v1.0.28
type GeoRadiusQuery = red.GeoRadiusQuery
GeoRadiusQuery is used with GeoRadius to query geospatial index.
type Option ¶ added in v1.1.7
type Option func(r *Redis)
Option defines the method to customize a Redis.
func Cluster ¶ added in v1.1.7
func Cluster() Option
Cluster customizes the given Redis as a cluster.
type Redis ¶
Redis defines a redis node/cluster. It is thread-safe.
func (*Redis) BitOpAnd ¶ added in v1.1.5
BitOpAnd is redis bit operation (and) command implementation.
func (*Redis) BitOpNot ¶ added in v1.1.5
BitOpNot is redis bit operation (not) command implementation.
func (*Redis) BitOpXor ¶ added in v1.1.5
BitOpXor is redis bit operation (xor) 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) 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 ¶ added in v1.1.6
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 ¶ added in v1.0.28
func (s *Redis) GeoAdd(key string, geoLocation ...*GeoLocation) (val int64, err error)
GeoAdd is the implementation of redis geoadd command.
func (*Redis) GeoRadius ¶ added in v1.0.28
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 ¶ added in v1.0.28
func (s *Redis) GeoRadiusByMember(key, member string, query *GeoRadiusQuery) (val []GeoLocation, err error)
GeoRadiusByMember is the implementation of redis georadiusbymember command.
func (*Redis) Hscan ¶ added in v1.1.5
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 ¶ added in v1.1.6
ScriptLoad is the implementation of redis script load command.
func (*Redis) Sdiffstore ¶
Sdiffstore is the implementation of redis sdiffstore command.
func (*Redis) Sinterstore ¶ added in v1.1.8
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:",default=false,options=true|false"` }
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.