Documentation ¶
Overview ¶
Package redis provides convenient API to redis storage. It uses redigo library undercover.
Typical simplified usage:
client := redis.MustNewClient(redis.WithAddress("127.0.0.1:6379")) conn := client.Conn() defer conn.Close() value, err := conn.Get("key").String() if err != nil { ... }
Index ¶
- Constants
- Variables
- type Client
- type Config
- type ConfigService
- type Conn
- func (conn *Conn) Append(key string, value interface{}) Reply
- func (conn *Conn) BLPop(args ...interface{}) Reply
- func (conn *Conn) BRPop(args ...interface{}) Reply
- func (conn *Conn) BRPopLPush(source string, destination string, timeout int64) Reply
- func (conn *Conn) BitCount(args ...interface{}) Reply
- func (conn *Conn) BitOp(args ...interface{}) Reply
- func (conn *Conn) Close() error
- func (conn *Conn) Decr(key string) Reply
- func (conn *Conn) DecrBy(key string, decrement int64) Reply
- func (conn *Conn) Del(args ...interface{}) Reply
- func (conn *Conn) Do(commandName string, args ...interface{}) Reply
- func (conn *Conn) Dump(key string) Reply
- func (conn *Conn) Eval(args ...interface{}) Reply
- func (conn *Conn) EvalSha(args ...interface{}) Reply
- func (conn *Conn) Exists(key string) Reply
- func (conn *Conn) Expire(key string, seconds int64) Reply
- func (conn *Conn) ExpireAt(key string, timestamp int64) Reply
- func (conn *Conn) Get(key string) Reply
- func (conn *Conn) GetBit(key string, offset int64) Reply
- func (conn *Conn) GetRange(key string, start int64, end int64) Reply
- func (conn *Conn) GetSet(key string, value interface{}) Reply
- func (conn *Conn) HDel(args ...interface{}) Reply
- func (conn *Conn) HExists(key string, field string) Reply
- func (conn *Conn) HGet(key string, field string) Reply
- func (conn *Conn) HGetAll(key string) Reply
- func (conn *Conn) HIncrBy(key string, field string, increment int64) Reply
- func (conn *Conn) HIncrByFloat(key string, field string, increment float64) Reply
- func (conn *Conn) HKeys(key string) Reply
- func (conn *Conn) HLen(key string) Reply
- func (conn *Conn) HMGet(args ...interface{}) Reply
- func (conn *Conn) HMSet(key string, values map[string]interface{}) Reply
- func (conn *Conn) HMSetFlat(args ...interface{}) Reply
- func (conn *Conn) HSet(key string, field string, value interface{}) Reply
- func (conn *Conn) HSetNx(key string, field string, value interface{}) Reply
- func (conn *Conn) HVals(key string) Reply
- func (conn *Conn) Incr(key string) Reply
- func (conn *Conn) IncrBy(key string, increment int64) Reply
- func (conn *Conn) IncrByFloat(key string, increment float64) Reply
- func (conn *Conn) Keys(pattern string) Reply
- func (conn *Conn) LIndex(key string, index int64) Reply
- func (conn *Conn) LInsertAfter(key string, pivot interface{}, value interface{}) Reply
- func (conn *Conn) LInsertBefore(key string, pivot interface{}, value interface{}) Reply
- func (conn *Conn) LLen(key string) Reply
- func (conn *Conn) LPop(key string) Reply
- func (conn *Conn) LPush(args ...interface{}) Reply
- func (conn *Conn) LPushX(args ...interface{}) Reply
- func (conn *Conn) LRange(key string, start int64, stop int64) Reply
- func (conn *Conn) LRem(key string, count int64, value interface{}) Reply
- func (conn *Conn) LSet(key string, index int64, value interface{}) Reply
- func (conn *Conn) LTrim(key string, start int64, stop int64) Reply
- func (conn *Conn) MGet(args ...interface{}) Reply
- func (conn *Conn) MSet(values map[string]interface{}) Reply
- func (conn *Conn) MSetFlat(args ...interface{}) Reply
- func (conn *Conn) MSetNx(values map[string]interface{}) Reply
- func (conn *Conn) MSetNxFlat(args ...interface{}) Reply
- func (conn *Conn) Move(key string, db int64) Reply
- func (conn *Conn) MultiCall(f MultiCallFunc) Reply
- func (conn *Conn) Object(args ...interface{}) Reply
- func (conn *Conn) PExpire(key string, milliseconds int64) Reply
- func (conn *Conn) PExpireAt(key string, mtimestamp int64) Reply
- func (conn *Conn) PSetEx(key string, milliseconds int64, value interface{}) Reply
- func (conn *Conn) PTTL(key string) Reply
- func (conn *Conn) Persist(key string) Reply
- func (conn *Conn) RPop(key string) Reply
- func (conn *Conn) RPopLPush(source string, destination string) Reply
- func (conn *Conn) RPush(args ...interface{}) Reply
- func (conn *Conn) RPushX(args ...interface{}) Reply
- func (conn *Conn) RandomKey() Reply
- func (conn *Conn) Rename(key string, newkey string) Reply
- func (conn *Conn) RenameNx(key string, newkey string) Reply
- func (conn *Conn) Restore(key string, ttl int64, value interface{}) Reply
- func (conn *Conn) SAdd(args ...interface{}) Reply
- func (conn *Conn) SCard(key string) Reply
- func (conn *Conn) SDiff(args ...interface{}) Reply
- func (conn *Conn) SDiffStore(args ...interface{}) Reply
- func (conn *Conn) SInter(args ...interface{}) Reply
- func (conn *Conn) SInterStore(args ...interface{}) Reply
- func (conn *Conn) SIsMember(key string, member interface{}) Reply
- func (conn *Conn) SMembers(key string) Reply
- func (conn *Conn) SMove(source string, destination string, member interface{}) Reply
- func (conn *Conn) SPop(key string) Reply
- func (conn *Conn) SRandMember(key string) Reply
- func (conn *Conn) SRandMemberCount(key string, count int64) Reply
- func (conn *Conn) SRem(args ...interface{}) Reply
- func (conn *Conn) SUnion(args ...interface{}) Reply
- func (conn *Conn) SUnionStore(args ...interface{}) Reply
- func (conn *Conn) ScriptExists(args ...interface{}) Reply
- func (conn *Conn) ScriptFlush() Reply
- func (conn *Conn) ScriptKill() Reply
- func (conn *Conn) ScriptLoad(script string) Reply
- func (conn *Conn) Set(key string, value interface{}) Reply
- func (conn *Conn) SetAdvanced(args ...interface{}) Reply
- func (conn *Conn) SetBit(key string, offset int64, value interface{}) Reply
- func (conn *Conn) SetEx(key string, seconds int64, value interface{}) Reply
- func (conn *Conn) SetNx(key string, value interface{}) Reply
- func (conn *Conn) SetRange(key string, offset int64, value interface{}) Reply
- func (conn *Conn) Sort(args ...interface{}) Reply
- func (conn *Conn) StrLen(key string) Reply
- func (conn *Conn) TTL(key string) Reply
- func (conn *Conn) Transaction(f MultiCallFunc) Reply
- func (conn *Conn) Type(key string) Reply
- func (conn *Conn) ZAdd(args ...interface{}) Reply
- func (conn *Conn) ZCard(key string) Reply
- func (conn *Conn) ZCount(key string, min interface{}, max interface{}) Reply
- func (conn *Conn) ZIncrBy(key string, increment int64, member interface{}) Reply
- func (conn *Conn) ZIncrByFloat(key string, increment float64, member interface{}) Reply
- func (conn *Conn) ZInterStore(args ...interface{}) Reply
- func (conn *Conn) ZRange(key string, start int64, stop int64) Reply
- func (conn *Conn) ZRangeByScore(key string, min interface{}, max interface{}) Reply
- func (conn *Conn) ZRangeByScoreWithLimit(key string, min interface{}, max interface{}, offset int64, count int64) Reply
- func (conn *Conn) ZRangeByScoreWithScores(key string, min interface{}, max interface{}) Reply
- func (conn *Conn) ZRangeByScoreWithScoresWithLimit(key string, min interface{}, max interface{}, offset int64, count int64) Reply
- func (conn *Conn) ZRangeWithScores(key string, start int64, stop int64) Reply
- func (conn *Conn) ZRank(key string, member interface{}) Reply
- func (conn *Conn) ZRem(args ...interface{}) Reply
- func (conn *Conn) ZRemRangeByRank(key string, start int64, stop int64) Reply
- func (conn *Conn) ZRemRangeByScore(key string, min interface{}, max interface{}) Reply
- func (conn *Conn) ZRevRange(key string, start int64, stop int64) Reply
- func (conn *Conn) ZRevRangeByScore(key string, max interface{}, min interface{}) Reply
- func (conn *Conn) ZRevRangeByScoreWithLimit(key string, max interface{}, min interface{}, offset int64, count int64) Reply
- func (conn *Conn) ZRevRangeByScoreWithScores(key string, max interface{}, min interface{}) Reply
- func (conn *Conn) ZRevRangeByScoreWithScoresWithLimit(key string, max interface{}, min interface{}, offset int64, count int64) Reply
- func (conn *Conn) ZRevRangeWithScores(key string, start int64, stop int64) Reply
- func (conn *Conn) ZRevRank(key string, member interface{}) Reply
- func (conn *Conn) ZScore(key string, member interface{}) Reply
- func (conn *Conn) ZUnionStore(args ...interface{}) Reply
- type MultiCall
- func (multiCall MultiCall) Append(key string, value interface{}) error
- func (multiCall MultiCall) BitOp(args ...interface{}) error
- func (multiCall MultiCall) Decr(key string) error
- func (multiCall MultiCall) DecrBy(key string, decrement int64) error
- func (multiCall MultiCall) Del(args ...interface{}) error
- func (multiCall MultiCall) Eval(args ...interface{}) error
- func (multiCall MultiCall) EvalSha(args ...interface{}) error
- func (multiCall MultiCall) Expire(key string, seconds int64) error
- func (multiCall MultiCall) ExpireAt(key string, timestamp int64) error
- func (multiCall MultiCall) HDel(args ...interface{}) error
- func (multiCall MultiCall) HIncrBy(key string, field string, increment int64) error
- func (multiCall MultiCall) HIncrByFloat(key string, field string, increment float64) error
- func (multiCall MultiCall) HMSet(key string, values map[string]interface{}) error
- func (multiCall MultiCall) HMSetFlat(args ...interface{}) error
- func (multiCall MultiCall) HSet(key string, field string, value interface{}) error
- func (multiCall MultiCall) HSetNx(key string, field string, value interface{}) error
- func (multiCall MultiCall) Incr(key string) error
- func (multiCall MultiCall) IncrBy(key string, increment int64) error
- func (multiCall MultiCall) IncrByFloat(key string, increment float64) error
- func (multiCall MultiCall) LInsertAfter(key string, pivot interface{}, value interface{}) error
- func (multiCall MultiCall) LInsertBefore(key string, pivot interface{}, value interface{}) error
- func (multiCall MultiCall) LPush(args ...interface{}) error
- func (multiCall MultiCall) LPushX(key string, value interface{}) error
- func (multiCall MultiCall) LRem(key string, count int64, value interface{}) error
- func (multiCall MultiCall) LSet(key string, index int64, value interface{}) error
- func (multiCall MultiCall) LTrim(key string, start int64, stop int64) error
- func (multiCall MultiCall) MSet(values map[string]interface{}) error
- func (multiCall MultiCall) MSetFlat(args ...interface{}) error
- func (multiCall MultiCall) MSetNx(values map[string]interface{}) error
- func (multiCall MultiCall) MSetNxFlat(args ...interface{}) error
- func (multiCall MultiCall) Move(key string, db int64) error
- func (multiCall MultiCall) PExpire(key string, milliseconds int64) error
- func (multiCall MultiCall) PExpireAt(key string, mtimestamp int64) error
- func (multiCall MultiCall) PSetEx(key string, milliseconds int64, value interface{}) error
- func (multiCall MultiCall) Persist(key string) error
- func (multiCall MultiCall) RPopLPush(source string, destination string) error
- func (multiCall MultiCall) RPush(args ...interface{}) error
- func (multiCall MultiCall) RPushX(key string, value interface{}) error
- func (multiCall MultiCall) Rename(key string, newkey string) error
- func (multiCall MultiCall) RenameNx(key string, newkey string) error
- func (multiCall MultiCall) Restore(key string, ttl int64, value interface{}) error
- func (multiCall MultiCall) SAdd(args ...interface{}) error
- func (multiCall MultiCall) SDiffStore(args ...interface{}) error
- func (multiCall MultiCall) SInterStore(args ...interface{}) error
- func (multiCall MultiCall) SMove(source string, destination string, member interface{}) error
- func (multiCall MultiCall) SRem(args ...interface{}) error
- func (multiCall MultiCall) SUnionStore(args ...interface{}) error
- func (multiCall MultiCall) ScriptFlush() error
- func (multiCall MultiCall) ScriptKill() error
- func (multiCall MultiCall) Send(commandName string, args ...interface{}) error
- func (multiCall MultiCall) Set(key string, value interface{}) error
- func (multiCall MultiCall) SetAdvanced(args ...interface{}) error
- func (multiCall MultiCall) SetBit(key string, offset int64, value interface{}) error
- func (multiCall MultiCall) SetEx(key string, seconds int64, value interface{}) error
- func (multiCall MultiCall) SetNx(key string, value interface{}) error
- func (multiCall MultiCall) SetRange(key string, offset int64, value interface{}) error
- func (multiCall MultiCall) ZAdd(args ...interface{}) error
- func (multiCall MultiCall) ZIncrBy(key string, increment int64, member interface{}) error
- func (multiCall MultiCall) ZIncrByFloat(key string, increment float64, member interface{}) error
- func (multiCall MultiCall) ZInterStore(args ...interface{}) error
- func (multiCall MultiCall) ZRem(args ...interface{}) error
- func (multiCall MultiCall) ZRemRangeByRank(key string, start int64, stop int64) error
- func (multiCall MultiCall) ZRemRangeByScore(key string, min interface{}, max interface{}) error
- func (multiCall MultiCall) ZUnionStore(args ...interface{}) error
- type MultiCallFunc
- type Option
- type Reply
- func (reply Reply) Bool() (bool, error)
- func (reply Reply) Bytes() ([]byte, error)
- func (reply Reply) Error() error
- func (reply Reply) Float64() (float64, error)
- func (reply Reply) Int() (int, error)
- func (reply Reply) Int64() (int64, error)
- func (reply Reply) IsError() bool
- func (reply Reply) IsNil() bool
- func (reply Reply) List() ([]string, error)
- func (reply Reply) Map() (map[string]string, error)
- func (reply Reply) Scan(args ...interface{}) error
- func (reply Reply) ScanStruct(dest interface{}) error
- func (reply Reply) String() (string, error)
- type TransConn
- func (conn *TransConn) Append(key string, value interface{}) error
- func (conn *TransConn) BitOp(args ...interface{}) error
- func (conn *TransConn) Close() error
- func (conn *TransConn) Decr(key string) error
- func (conn *TransConn) DecrBy(key string, decrement int64) error
- func (conn *TransConn) Del(args ...interface{}) error
- func (conn *TransConn) Discard() Reply
- func (conn *TransConn) Eval(args ...interface{}) error
- func (conn *TransConn) EvalSha(args ...interface{}) error
- func (conn *TransConn) Exec() Reply
- func (conn *TransConn) Expire(key string, seconds int64) error
- func (conn *TransConn) ExpireAt(key string, timestamp int64) error
- func (conn *TransConn) HDel(args ...interface{}) error
- func (conn *TransConn) HIncrBy(key string, field string, increment int64) error
- func (conn *TransConn) HIncrByFloat(key string, field string, increment float64) error
- func (conn *TransConn) HMSet(key string, values map[string]interface{}) error
- func (conn *TransConn) HMSetFlat(args ...interface{}) error
- func (conn *TransConn) HSet(key string, field string, value interface{}) error
- func (conn *TransConn) HSetNx(key string, field string, value interface{}) error
- func (conn *TransConn) Incr(key string) error
- func (conn *TransConn) IncrBy(key string, increment int64) error
- func (conn *TransConn) IncrByFloat(key string, increment float64) error
- func (conn *TransConn) LInsertAfter(key string, pivot interface{}, value interface{}) error
- func (conn *TransConn) LInsertBefore(key string, pivot interface{}, value interface{}) error
- func (conn *TransConn) LPush(args ...interface{}) error
- func (conn *TransConn) LPushX(key string, value interface{}) error
- func (conn *TransConn) LRem(key string, count int64, value interface{}) error
- func (conn *TransConn) LSet(key string, index int64, value interface{}) error
- func (conn *TransConn) LTrim(key string, start int64, stop int64) error
- func (conn *TransConn) MSet(values map[string]interface{}) error
- func (conn *TransConn) MSetFlat(args ...interface{}) error
- func (conn *TransConn) MSetNx(values map[string]interface{}) error
- func (conn *TransConn) MSetNxFlat(args ...interface{}) error
- func (conn *TransConn) Move(key string, db int64) error
- func (conn *TransConn) PExpire(key string, milliseconds int64) error
- func (conn *TransConn) PExpireAt(key string, mtimestamp int64) error
- func (conn *TransConn) PSetEx(key string, milliseconds int64, value interface{}) error
- func (conn *TransConn) Persist(key string) error
- func (conn *TransConn) RPopLPush(source string, destination string) error
- func (conn *TransConn) RPush(args ...interface{}) error
- func (conn *TransConn) RPushX(key string, value interface{}) error
- func (conn *TransConn) Rename(key string, newkey string) error
- func (conn *TransConn) RenameNx(key string, newkey string) error
- func (conn *TransConn) Restore(key string, ttl int64, value interface{}) error
- func (conn *TransConn) SAdd(args ...interface{}) error
- func (conn *TransConn) SDiffStore(args ...interface{}) error
- func (conn *TransConn) SInterStore(args ...interface{}) error
- func (conn *TransConn) SMove(source string, destination string, member interface{}) error
- func (conn *TransConn) SRem(args ...interface{}) error
- func (conn *TransConn) SUnionStore(args ...interface{}) error
- func (conn *TransConn) ScriptFlush() error
- func (conn *TransConn) ScriptKill() error
- func (conn *TransConn) Send(commandName string, args ...interface{}) error
- func (conn *TransConn) Set(key string, value interface{}) error
- func (conn *TransConn) SetAdvanced(args ...interface{}) error
- func (conn *TransConn) SetBit(key string, offset int64, value interface{}) error
- func (conn *TransConn) SetEx(key string, seconds int64, value interface{}) error
- func (conn *TransConn) SetNx(key string, value interface{}) error
- func (conn *TransConn) SetRange(key string, offset int64, value interface{}) error
- func (conn *TransConn) ZAdd(args ...interface{}) error
- func (conn *TransConn) ZIncrBy(key string, increment int64, member interface{}) error
- func (conn *TransConn) ZIncrByFloat(key string, increment float64, member interface{}) error
- func (conn *TransConn) ZInterStore(args ...interface{}) error
- func (conn *TransConn) ZRem(args ...interface{}) error
- func (conn *TransConn) ZRemRangeByRank(key string, start int64, stop int64) error
- func (conn *TransConn) ZRemRangeByScore(key string, min interface{}, max interface{}) error
- func (conn *TransConn) ZUnionStore(args ...interface{}) error
Constants ¶
const ( // DefAddress is the default redis server address. DefAddress = "127.0.0.1:6379" // DefMaxIdle is the default maximum number of idle redis connections in the pool. DefMaxIdle = 3 // DefIdleTimeout is the default timeout in seconds after which idle connections will be dropped away. DefIdleTimeout = 600 )
Variables ¶
var ErrNoValues = errors.New("no values")
ErrNoValues error is returned by Scan and ScanStruct reply methods when there are no values returned by redis server, i.e. reply was empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client structure provides redis client functionality. Don't create manually, use the functions down below instead.
func MustNewClient ¶
MustNewClient function creates new redis client with provided options and panics on any error.
func (*Client) Close ¶
Close method releases all resources used by client. Don't use client object after that.
func (*Client) Conn ¶
Conn method retrieves idle connection from the pool (if there are none, it will be created).
func (*Client) IdleTimeout ¶
IdleTimeout method retrieves timeout in seconds after which idle connections will be dropped away.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config structure with client's configuration. Shouldn't be created manually.
type ConfigService ¶
ConfigService interface used to obtain configuration from somewhere into some specific structure.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn structure represents connection to redis server retrieved from the pool.
func (*Conn) Append ¶
Append method sends APPEND command to the redis server and waits for the reply.
func (*Conn) BRPopLPush ¶
BRPopLPush method sends BRPOPLPUSH command to the redis server and waits for the reply.
func (*Conn) BitCount ¶
BitCount method sends BITCOUNT command to the redis server and waits for the reply.
func (*Conn) Close ¶
Close method returns connection to the pool. Don't use connection object after that.
func (*Conn) DecrBy ¶
DecrBy method sends DECRBY command to the redis server and waits for the reply.
func (*Conn) Do ¶
Do method sends specified command with arguments to the redis server and waits for the reply.
func (*Conn) EvalSha ¶
EvalSha method sends EVALSHA command to the redis server and waits for the reply.
func (*Conn) Exists ¶
Exists method sends EXISTS command to the redis server and waits for the reply.
func (*Conn) Expire ¶
Expire method sends EXPIRE command to the redis server and waits for the reply.
func (*Conn) ExpireAt ¶
ExpireAt method sends EXPIREAT command to the redis server and waits for the reply.
func (*Conn) GetBit ¶
GetBit method sends GETBIT command to the redis server and waits for the reply.
func (*Conn) GetRange ¶
GetRange method sends GETRANGE command to the redis server and waits for the reply.
func (*Conn) GetSet ¶
GetSet method sends GETSET command to the redis server and waits for the reply.
func (*Conn) HExists ¶
HExists method sends HEXISTS command to the redis server and waits for the reply.
func (*Conn) HGetAll ¶
HGetAll method sends HGETALL command to the redis server and waits for the reply.
func (*Conn) HIncrBy ¶
HIncrBy method sends HINCRBY command to the redis server and waits for the reply.
func (*Conn) HIncrByFloat ¶
HIncrByFloat method sends HINCRBYFLOAT command to the redis server and waits for the reply.
func (*Conn) HMSet ¶
HMSet method unfolds provided map, sends HMSET command to the redis server and waits for the reply.
func (*Conn) HMSetFlat ¶
HMSetFlat method sends HMSET command to the redis server and waits for the reply.
func (*Conn) HSetNx ¶
HSetNx method sends HSETNX command to the redis server and waits for the reply.
func (*Conn) IncrBy ¶
IncrBy method sends INCRBY command to the redis server and waits for the reply.
func (*Conn) IncrByFloat ¶
IncrByFloat method sends INCRBYFLOAT command to the redis server and waits for the reply.
func (*Conn) LIndex ¶
LIndex method sends LINDEX command to the redis server and waits for the reply.
func (*Conn) LInsertAfter ¶
LInsertAfter method sends LINSERT command with AFTER modifier to the redis server and waits for the reply.
func (*Conn) LInsertBefore ¶
LInsertBefore method sends LINSERT command with BEFORE modifier to the redis server and waits for the reply.
func (*Conn) LPushX ¶
LPushX method sends LPUSHX command to the redis server and waits for the reply.
func (*Conn) LRange ¶
LRange method sends LRANGE command to the redis server and waits for the reply.
func (*Conn) MSet ¶
MSet method unfolds provided map, sends MSET command to the redis server and waits for the reply.
func (*Conn) MSetFlat ¶
MSetFlat method sends MSET command to the redis server and waits for the reply.
func (*Conn) MSetNx ¶
MSetNx method unfolds provided map, sends MSETNX command to the redis server and waits for the reply.
func (*Conn) MSetNxFlat ¶
MSetNxFlat method sends MSETNX command to the redis server and waits for the reply.
func (*Conn) MultiCall ¶
func (conn *Conn) MultiCall(f MultiCallFunc) Reply
MultiCall method wraps calling of provided function for bulk processing. It will return unified reply of all commands that were sent in this function.
func (*Conn) Object ¶
Object method sends OBJECT command to the redis server and waits for the reply.
func (*Conn) PExpire ¶
PExpire method sends PEXPIRE command to the redis server and waits for the reply.
func (*Conn) PExpireAt ¶
PExpireAt method sends PEXPIREAT command to the redis server and waits for the reply.
func (*Conn) PSetEx ¶
PSetEx method sends PSETEX command to the redis server and waits for the reply.
func (*Conn) Persist ¶
Persist method sends PERSIST command to the redis server and waits for the reply.
func (*Conn) RPopLPush ¶
RPopLPush method sends RPOPLPUSH command to the redis server and waits for the reply.
func (*Conn) RPushX ¶
RPushX method sends RPUSHX command to the redis server and waits for the reply.
func (*Conn) RandomKey ¶
RandomKey method sends RANDOMKEY command to the redis server and waits for the reply.
func (*Conn) Rename ¶
Rename method sends RENAME command to the redis server and waits for the reply.
func (*Conn) RenameNx ¶
RenameNx method sends RENAMENX command to the redis server and waits for the reply.
func (*Conn) Restore ¶
Restore method sends RESTORE command to the redis server and waits for the reply.
func (*Conn) SDiffStore ¶
SDiffStore method sends SDIFFSTORE command to the redis server and waits for the reply.
func (*Conn) SInter ¶
SInter method sends SINTER command to the redis server and waits for the reply.
func (*Conn) SInterStore ¶
SInterStore method sends SINTERSTORE command to the redis server and waits for the reply.
func (*Conn) SIsMember ¶
SIsMember method sends SISMEMBER command to the redis server and waits for the reply.
func (*Conn) SMembers ¶
SMembers method sends SMEMBERS command to the redis server and waits for the reply.
func (*Conn) SRandMember ¶
SRandMember method sends SRANDMEMBER command to the redis server and waits for the reply.
func (*Conn) SRandMemberCount ¶
SRandMemberCount method sends SRANDMEMBER command with count param to the redis server and waits for the reply.
func (*Conn) SUnion ¶
SUnion method sends SUNION command to the redis server and waits for the reply.
func (*Conn) SUnionStore ¶
SUnionStore method sends SUNIONSTORE command to the redis server and waits for the reply.
func (*Conn) ScriptExists ¶
ScriptExists method sends SCRIPT EXISTS command to the redis server and waits for the reply.
func (*Conn) ScriptFlush ¶
ScriptFlush method sends SCRIPT FLUSH command to the redis server and waits for the reply.
func (*Conn) ScriptKill ¶
ScriptKill method sends SCRIPT KILL command to the redis server and waits for the reply.
func (*Conn) ScriptLoad ¶
ScriptLoad method sends SCRIPT LOAD command to the redis server and waits for the reply.
func (*Conn) SetAdvanced ¶
SetAdvanced method sends SET command with any provided advanced args to the redis server and waits for the reply.
func (*Conn) SetBit ¶
SetBit method sends SETBIT command to the redis server and waits for the reply.
func (*Conn) SetRange ¶
SetRange method sends SETRANGE command to the redis server and waits for the reply.
func (*Conn) StrLen ¶
StrLen method sends STRLEN command to the redis server and waits for the reply.
func (*Conn) Transaction ¶
func (conn *Conn) Transaction(f MultiCallFunc) Reply
Transaction method wraps calling of provided function for transaction processing, i.e. it will send MULTI command before and EXEC command after. Then it will return unified reply of all commands that were sent.
func (*Conn) ZCount ¶
ZCount method sends ZCOUNT command to the redis server and waits for the reply.
func (*Conn) ZIncrBy ¶
ZIncrBy method sends ZINCRBY command to the redis server and waits for the reply.
func (*Conn) ZIncrByFloat ¶
ZIncrByFloat method sends ZINCRBY command with float increment to the redis server and waits for the reply.
func (*Conn) ZInterStore ¶
ZInterStore method sends ZINTERSTORE command to the redis server and waits for the reply.
func (*Conn) ZRange ¶
ZRange method sends ZRANGE command to the redis server and waits for the reply.
func (*Conn) ZRangeByScore ¶
ZRangeByScore method sends ZRANGEBYSCORE command to the redis server and waits for the reply.
func (*Conn) ZRangeByScoreWithLimit ¶
func (conn *Conn) ZRangeByScoreWithLimit( key string, min interface{}, max interface{}, offset int64, count int64, ) Reply
ZRangeByScoreWithLimit method sends ZRANGEBYSCORE command with LIMIT modifier to the redis server and waits for the reply.
func (*Conn) ZRangeByScoreWithScores ¶
ZRangeByScoreWithScores method sends ZRANGEBYSCORE command with WITHSCORES modifier to the redis server and waits for the reply.
func (*Conn) ZRangeByScoreWithScoresWithLimit ¶
func (conn *Conn) ZRangeByScoreWithScoresWithLimit(key string, min interface{}, max interface{}, offset int64, count int64, ) Reply
ZRangeByScoreWithScoresWithLimit method sends ZRANGEBYSCORE command with WITHSCORES and LIMIT modifiers to the redis server and waits for the reply.
func (*Conn) ZRangeWithScores ¶
ZRangeWithScores method sends ZRANGE command with WITHSCORES modifier to the redis server and waits for the reply.
func (*Conn) ZRemRangeByRank ¶
ZRemRangeByRank method sends ZREMRANGEBYRANK command to the redis server and waits for the reply.
func (*Conn) ZRemRangeByScore ¶
ZRemRangeByScore method sends ZREMRANGEBYSCORE command to the redis server and waits for the reply.
func (*Conn) ZRevRange ¶
ZRevRange method sends ZREVRANGE command to the redis server and waits for the reply.
func (*Conn) ZRevRangeByScore ¶
ZRevRangeByScore method sends ZREVRANGEBYSCORE command to the redis server and waits for the reply.
func (*Conn) ZRevRangeByScoreWithLimit ¶
func (conn *Conn) ZRevRangeByScoreWithLimit( key string, max interface{}, min interface{}, offset int64, count int64, ) Reply
ZRevRangeByScoreWithLimit method sends ZREVRANGEBYSCORE command with LIMIT modifier to the redis server and waits for the reply.
func (*Conn) ZRevRangeByScoreWithScores ¶
ZRevRangeByScoreWithScores method sends ZREVRANGEBYSCORE command with WITHSCORES modifier to the redis server and waits for the reply.
func (*Conn) ZRevRangeByScoreWithScoresWithLimit ¶
func (conn *Conn) ZRevRangeByScoreWithScoresWithLimit( key string, max interface{}, min interface{}, offset int64, count int64, ) Reply
ZRevRangeByScoreWithScoresWithLimit method sends ZREVRANGEBYSCORE command with WITHSCORES and LIMIT modifiers to the redis server and waits for the reply.
func (*Conn) ZRevRangeWithScores ¶
ZRevRangeWithScores method sends ZREVRANGE command with WITHSCORES modifier to the redis server and waits for the reply.
func (*Conn) ZRevRank ¶
ZRevRank method sends ZREVRANK command to the redis server and waits for the reply.
func (*Conn) ZScore ¶
ZScore method sends ZSCORE command to the redis server and waits for the reply.
func (*Conn) ZUnionStore ¶
ZUnionStore method sends ZUNIONSTORE command to the redis server and waits for the reply.
type MultiCall ¶
type MultiCall struct {
// contains filtered or unexported fields
}
MultiCall structure is a bulk or transaction processing context. Do not create it manually. Use it inside MultiCallFunc to send commands that are part of that bulk or transaction processing.
func (MultiCall) HIncrByFloat ¶
HIncrByFloat method sends HINCRBYFLOAT command to the redis server.
func (MultiCall) HMSet ¶
HMSet method unfolds provided map and sends HMSET command to the redis server.
func (MultiCall) IncrByFloat ¶
IncrByFloat method sends INCRBYFLOAT command to the redis server.
func (MultiCall) LInsertAfter ¶
LInsertAfter method sends LINSERT command with AFTER modifier to the redis server.
func (MultiCall) LInsertBefore ¶
LInsertBefore method sends LINSERT command with BEFORE modifier to the redis server.
func (MultiCall) MSet ¶
MSet method unfolds provided map and sends MSET command to the redis server.
func (MultiCall) MSetNx ¶
MSetNx method unfolds provided map and sends MSETNX command to the redis server.
func (MultiCall) MSetNxFlat ¶
MSetNxFlat method sends MSETNX command to the redis server.
func (MultiCall) SDiffStore ¶
SDiffStore method sends SDIFFSTORE command to the redis server.
func (MultiCall) SInterStore ¶
SInterStore method sends SINTERSTORE command to the redis server.
func (MultiCall) SUnionStore ¶
SUnionStore method sends SUNIONSTORE command to the redis server.
func (MultiCall) ScriptFlush ¶
ScriptFlush method sends SCRIPT FLUSH command to the redis server.
func (MultiCall) ScriptKill ¶
ScriptKill method sends SCRIPT KILL command to the redis server.
func (MultiCall) Send ¶
Send method sends provided command and arguments to redis server as part of bulk or transaction processing. Generally you will not call this method directly, but use helper command methods instead.
func (MultiCall) SetAdvanced ¶
SetAdvanced method sends SET command with any provided advanced args to the redis server.
func (MultiCall) ZIncrByFloat ¶
ZIncrByFloat method sends ZINCRBY command with float increment to the redis server.
func (MultiCall) ZInterStore ¶
ZInterStore method sends ZINTERSTORE command to the redis server.
func (MultiCall) ZRemRangeByRank ¶
ZRemRangeByRank method sends ZREMRANGEBYRANK command to the redis server.
func (MultiCall) ZRemRangeByScore ¶
ZRemRangeByScore method sends ZREMRANGEBYSCORE command to the redis server.
func (MultiCall) ZUnionStore ¶
ZUnionStore method sends ZUNIONSTORE command to the redis server.
type MultiCallFunc ¶
MultiCallFunc is a function that will be wrapped in bulk and transaction processing. Inside it should call all necessary commands to redis server using provided MultiCall context.
type Option ¶
Option function that is fed to NewClient and MustNewClient. Obtain them using 'With' functions down below.
func WithAddress ¶
WithAddress option applies provided redis server address. Default: "127.0.0.1:6379".
func WithConfig ¶
func WithConfig(service ConfigService, key string) Option
WithConfig option retrieves configuration from provided configuration service.
Example JSON configuration with all possible fields (if some are not present, defaults will be used):
{ "address": "127.0.0.1:6379", "maxIdle": 5, "idleTimeout": 300 }
func WithDealFunc ¶
WithDealFunc option applies provided custom dial function instead of the default one. Used primarily in tests to mock redis connection.
func WithIdleTimeout ¶
WithIdleTimeout option applies provided timeout in seconds after which idle connections will be dropped away. Default: 600.
func WithMaxIdle ¶
WithMaxIdle option applies provided maximum number of idle redis connections in the pool. Default: 3.
type Reply ¶
type Reply struct {
// contains filtered or unexported fields
}
Reply structure represents some reply returned from redis server.
func (Reply) Float64 ¶
Float64 method tries to represent returned data as a number with a float point.
func (Reply) Scan ¶
Scan method tries to put returned data into provided arguments (that must be pointers) in order.
func (Reply) ScanStruct ¶
ScanStruct method tries to put returned data into a structure that is pointed to by the dest argument. For this method to work properly, the returned data must be a map of some sort (such as the HGETALL command returns).
You can use 'redis' tag and RedisScan methods to control scanning behavior. Nil values in reply data are silently ignored.
type TransConn ¶
type TransConn struct {
// contains filtered or unexported fields
}
TransConn structure represents connection to redis server retrieved from the pool. It is specially wrapped to send all the commands as part of some transaction.
func (*TransConn) Close ¶
Close method returns connection to the pool. Don't use connection object after that.
func (*TransConn) Discard ¶
Discard method sends DISCARD command to redis server and waits for the reply.
func (*TransConn) HIncrByFloat ¶
HIncrByFloat method sends HINCRBYFLOAT command to the redis server.
func (*TransConn) HMSet ¶
HMSet method unfolds provided map and sends HMSET command to the redis server.
func (*TransConn) IncrByFloat ¶
IncrByFloat method sends INCRBYFLOAT command to the redis server.
func (*TransConn) LInsertAfter ¶
LInsertAfter method sends LINSERT command with AFTER modifier to the redis server.
func (*TransConn) LInsertBefore ¶
LInsertBefore method sends LINSERT command with BEFORE modifier to the redis server.
func (*TransConn) MSet ¶
MSet method unfolds provided map and sends MSET command to the redis server.
func (*TransConn) MSetNx ¶
MSetNx method unfolds provided map and sends MSETNX command to the redis server.
func (*TransConn) MSetNxFlat ¶
MSetNxFlat method sends MSETNX command to the redis server.
func (*TransConn) SDiffStore ¶
SDiffStore method sends SDIFFSTORE command to the redis server.
func (*TransConn) SInterStore ¶
SInterStore method sends SINTERSTORE command to the redis server.
func (*TransConn) SUnionStore ¶
SUnionStore method sends SUNIONSTORE command to the redis server.
func (*TransConn) ScriptFlush ¶
ScriptFlush method sends SCRIPT FLUSH command to the redis server.
func (*TransConn) ScriptKill ¶
ScriptKill method sends SCRIPT KILL command to the redis server.
func (*TransConn) Send ¶
Send method sends specified command with arguments to the redis server without waiting for reply. If connection is not in transaction state yet, it will send MULTI command automatically.
func (*TransConn) SetAdvanced ¶
SetAdvanced method sends SET command with any provided advanced args to the redis server.
func (*TransConn) ZIncrByFloat ¶
ZIncrByFloat method sends ZINCRBY command with float increment to the redis server.
func (*TransConn) ZInterStore ¶
ZInterStore method sends ZINTERSTORE command to the redis server.
func (*TransConn) ZRemRangeByRank ¶
ZRemRangeByRank method sends ZREMRANGEBYRANK command to the redis server.
func (*TransConn) ZRemRangeByScore ¶
ZRemRangeByScore method sends ZREMRANGEBYSCORE command to the redis server.
func (*TransConn) ZUnionStore ¶
ZUnionStore method sends ZUNIONSTORE command to the redis server.