Documentation ¶
Overview ¶
redis返回数据 Error: -Error message\r\n
Simple String: +OK\r\n
Integers: :1000\r\n(int64)
Bulk Strings: $6\r\nfoobar\r\n
$0\r\n\r\n $-1\r\n
Arrays: *2\r\n$3\r\nfoo\r\n$3\r\nbar\r\n
*0\r\n *-1\r\n
A client sends to the Redis server a RESP Array consisting of just Bulk Strings. A Redis server replies to clients sending any valid RESP data type as reply.
Index ¶
- Constants
- Variables
- func Debug(info, address string)
- func Now() string
- func Sum(key string) int
- type Conn
- func (c *Conn) APPEND(key, value string) (int64, error)
- func (c *Conn) AUTH(password string) (bool, error)
- func (c *Conn) BITCOUNT(key string) (int64, error)
- func (c *Conn) BITOP(op, dest string, keys []string) (int64, error)
- func (c *Conn) BITPOS()
- func (c *Conn) BLPOP(keys []string, timeout int) ([]interface{}, error)
- func (c *Conn) BRPOP(keys []string, timeout int) ([]interface{}, error)
- func (c *Conn) BRPOPLPUSH(source, dest string, timeout int) ([]byte, error)
- func (c *Conn) Call(command string, args ...interface{}) (interface{}, error)
- func (c *Conn) CallN(retry int, command string, args ...interface{}) (interface{}, error)
- func (c *Conn) Close()
- func (c *Conn) Copy(conn *Conn)
- func (c *Conn) DECR(key string) (int64, error)
- func (c *Conn) DECRBY(key string, num int) (int64, error)
- func (c *Conn) DEL(key string) (int64, error)
- func (c *Conn) DELMulti(keys []string) (int64, error)
- func (c *Conn) DUMP(key string) ([]byte, error)
- func (c *Conn) Discard() error
- func (c *Conn) EVAL(script string, numkeys int, keys []string, scriptArgs []string) (interface{}, error)
- func (c *Conn) EVALSHA(sha1 string, numkeys int, keys []string, scriptArgs []string) (interface{}, error)
- func (c *Conn) EXISTS(key string) (bool, error)
- func (c *Conn) EXPIRE(key string, seconds int64) (bool, error)
- func (c *Conn) EXPIREAT(key string, timestamp int64) (bool, error)
- func (c *Conn) GET(key string) ([]byte, error)
- func (c *Conn) GETBIT(key string, pos int) (int64, error)
- func (c *Conn) GETRANGE(key string, start, end int) ([]byte, error)
- func (c *Conn) GETSET(key, value string) ([]byte, error)
- func (c *Conn) HDEL(key string, fields []string) (int64, error)
- func (c *Conn) HEXISTS(key string, field string) (bool, error)
- func (c *Conn) HGET(key string, field string) ([]byte, error)
- func (c *Conn) HGETALL(key string) ([]interface{}, error)
- func (c *Conn) HGETALLMAP(key string) (map[string]string, error)
- func (c *Conn) HINCRBY(key string, field string, increment int) (int64, error)
- func (c *Conn) HINCRBYFLOAT(key string, field string, increment float64) ([]byte, error)
- func (c *Conn) HKEYS(key string) ([][]byte, error)
- func (c *Conn) HLEN(key string) (int64, error)
- func (c *Conn) HMGET(key string, fields []string) ([]interface{}, error)
- func (c *Conn) HMSET(key string, kv map[string]interface{}) ([]byte, error)
- func (c *Conn) HSCAN(key string, cursor int, match bool, pattern string, isCount bool, count int) (int, []interface{}, error)
- func (c *Conn) HSET(key, field string, value interface{}) (int64, error)
- func (c *Conn) HSETNX(key, field string, value interface{}) (int64, error)
- func (c *Conn) HVALS(key string) ([]interface{}, error)
- func (c *Conn) INCR(key string) (int64, error)
- func (c *Conn) INCRBY(key string, num int) (int64, error)
- func (c *Conn) INCRBYFLOAT(key string, f float64) ([]byte, error)
- func (c *Conn) Info() ([]byte, error)
- func (c *Conn) IsAlive() bool
- func (c *Conn) KEYS(pattern string) ([][]byte, error)
- func (c *Conn) LINDEX(key string, index int) ([]byte, error)
- func (c *Conn) LINSERT(key, dir, pivot, value string) (int64, error)
- func (c *Conn) LLEN(key string) (int64, error)
- func (c *Conn) LPOP(key string) ([]byte, error)
- func (c *Conn) LPUSH(key string, values []string) (int64, error)
- func (c *Conn) LPUSHX(key, value string) (int64, error)
- func (c *Conn) LRANGE(key string, start, end int) ([]interface{}, error)
- func (c *Conn) LREM(key string, count int, value string) (int64, error)
- func (c *Conn) LSET(key string, index int, value string) ([]byte, error)
- func (c *Conn) LTRIM(key string, start, end int) ([]byte, error)
- func (c *Conn) MGET(keys []string) ([]interface{}, error)
- func (c *Conn) MIGRATE(host, port, key, destDB string, timeout int, COPY, REPLACE bool) (bool, error)
- func (c *Conn) MOVE(key, db string) (bool, error)
- func (c *Conn) MSET(kv map[string]string) ([]byte, error)
- func (c *Conn) MSETNX(kv map[string]string) (int64, error)
- func (c *Conn) MULTI() error
- func (c *Conn) OBJECT(subcommand, key string) (interface{}, error)
- func (c *Conn) PERSIST(key string) (bool, error)
- func (c *Conn) PEXPIRE(key string, milliseconds int64) (bool, error)
- func (c *Conn) PEXPIREAT(key string, milliTimestamp int64) (bool, error)
- func (c *Conn) PFADD(key string, elements []string) (int64, error)
- func (c *Conn) PFCOUNT(keys []string) (int64, error)
- func (c *Conn) PFMERGE(destKey string, sourceKeys []string) ([]byte, error)
- func (c *Conn) PSETEX(key string, millonseconds int64, value string) ([]byte, error)
- func (c *Conn) PTTL(key string) (int64, error)
- func (c *Conn) PipeExec() ([]interface{}, error)
- func (c *Conn) PipeSend(command string, args ...interface{}) error
- func (c *Conn) QUIT()
- func (c *Conn) RANDOMKEY() ([]byte, error)
- func (c *Conn) RENAME(key, newkey string) ([]byte, error)
- func (c *Conn) RENAMENX(key, newkey string) (bool, error)
- func (c *Conn) RESTORE(key string, ttl int, serializedValue string) (bool, error)
- func (c *Conn) RPOP(key string) ([]byte, error)
- func (c *Conn) RPOPLPUSH(source, dest string) ([]byte, error)
- func (c *Conn) RPUSH(key string, values []string) (int64, error)
- func (c *Conn) RPUSHX(key, value string) (int64, error)
- func (c *Conn) SADD(key string, values []string) (int64, error)
- func (c *Conn) SCAN(cursor int, match bool, pattern string, isCount bool, count int) (int, []interface{}, error)
- func (c *Conn) SCARD(key string) (int64, error)
- func (c *Conn) SCRIPTEXISTS(scripts []string) ([]interface{}, error)
- func (c *Conn) SCRIPTFLUSH() ([]byte, error)
- func (c *Conn) SCRIPTKILL() ([]byte, error)
- func (c *Conn) SCRIPTLOAD(script string) ([]byte, error)
- func (c *Conn) SDIFF(keys []string) ([][]byte, error)
- func (c *Conn) SDIFFSTORE(key string, keys []string) (int64, error)
- func (c *Conn) SELECT(index int) ([]byte, error)
- func (c *Conn) SET(key, value string) ([]byte, error)
- func (c *Conn) SETBIT(key string, pos, value int) (int64, error)
- func (c *Conn) SETEX(key string, seconds int64, value string) ([]byte, error)
- func (c *Conn) SETNX(key, value string) (int64, error)
- func (c *Conn) SETRANGE(key string, offset int, value string) (int64, error)
- func (c *Conn) SINTER(keys []string) ([][]byte, error)
- func (c *Conn) SINTERSTORE(key string, keys []string) (int64, error)
- func (c *Conn) SISMEMBER(key, value string) (int64, error)
- func (c *Conn) SMEMBERS(key string) ([][]byte, error)
- func (c *Conn) SMOVE(srcKey, desKey, member string) (int64, error)
- func (c *Conn) SORT()
- func (c *Conn) SPOP(key string) ([]byte, error)
- func (c *Conn) SRANDMEMBER(key string, count int) ([][]byte, error)
- func (c *Conn) SREM(key string, values []string) (int64, error)
- func (c *Conn) SSCAN(key string, cursor int, match bool, pattern string, isCount bool, count int) (int, []interface{}, error)
- func (c *Conn) STRLEN(key string) (int64, error)
- func (c *Conn) SUNION(keys []string) ([][]byte, error)
- func (c *Conn) SUNIONSTORE(key string, keys []string) (int64, error)
- func (c *Conn) TTL(key string) (int64, error)
- func (c *Conn) TYPE(key string) ([]byte, error)
- func (c *Conn) TransExec() ([]interface{}, error)
- func (c *Conn) TransSend(command string, args ...interface{}) error
- func (c *Conn) Watch(keys []string) error
- func (c *Conn) ZADD(key string, keyScore map[string]interface{}) (int64, error)
- func (c *Conn) ZADDSpec(key string, score, value string) (int64, error)
- func (c *Conn) ZCARD(key string) (int64, error)
- func (c *Conn) ZCOUNT(key string, min, max float64) (int64, error)
- func (c *Conn) ZINCRBY(key string, increment interface{}, member string) ([]byte, error)
- func (c *Conn) ZINTERSTORE(destination string, numkeys int, keys []string, weights bool, ws []int, ...) (int64, error)
- func (c *Conn) ZRANGE(key string, start, stop int, withscores bool) ([]interface{}, error)
- func (c *Conn) ZRANGEBYSCORE(key string, min, max interface{}, withScores, limit bool, ...) ([]interface{}, error)
- func (c *Conn) ZRANK(key, member string) (int64, error)
- func (c *Conn) ZREM(key string, members []string) (int64, error)
- func (c *Conn) ZREMRANGEBYRANK(key string, min, max interface{}) (int64, error)
- func (c *Conn) ZREMRANGEBYSCORE(key string, min, max interface{}) (int64, error)
- func (c *Conn) ZREVRANGE(key string, start, stop int, withscores bool) ([]interface{}, error)
- func (c *Conn) ZREVRANGEBYSCORE(key string, max, min interface{}, withScores, limit bool, ...) ([]interface{}, error)
- func (c *Conn) ZREVRANK(key, member string) (int64, error)
- func (c *Conn) ZSCAN(key string, cursor int, match bool, pattern string, isCount bool, count int) (int, []interface{}, error)
- func (c *Conn) ZSCORE(key, member string) ([]byte, error)
- func (c *Conn) ZUNIONSTORE(destination string, numkeys int, keys []string, weights bool, ws []int, ...) (int64, error)
- type MultiPool
- func (mp *MultiPool) AddPool(address string) (*Pool, bool)
- func (mp *MultiPool) Call(address string) *OnceConn
- func (mp *MultiPool) ClearInfo()
- func (mp *MultiPool) DelPool(address string)
- func (mp *MultiPool) Info() string
- func (mp *MultiPool) PopByAddr(addr string) *Conn
- func (mp *MultiPool) PopByKey(key string) *Conn
- func (mp *MultiPool) Push(c *Conn)
- func (mp *MultiPool) PushByAddr(addr string, c *Conn)
- func (mp *MultiPool) PushByKey(key string, c *Conn)
- func (mp *MultiPool) ReplacePool(src, dst string, maxConnNum, maxIdleNum int, maxIdleSeconds int64) bool
- type OnceConn
- type Pool
- func (p *Pool) Actives() int
- func (p *Pool) AddScriptSha1(name, script string)
- func (p *Pool) ClearInfo()
- func (p *Pool) DelScriptSha1(name string)
- func (p *Pool) GetScriptSha1(name string) string
- func (p *Pool) Idles() int
- func (p *Pool) Info() *PoolInfo
- func (p *Pool) Pop() *Conn
- func (p *Pool) Push(c *Conn)
- func (p *Pool) QPS() int64
- func (p *Pool) QPSAvg() int64
- type PoolInfo
Constants ¶
View Source
const ( ConnectTimeout = 10e9 ReadTimeout = 60e9 WriteTimeout = 60e9 DefaultBufferSize = 64 RetryWaitSeconds = time.Second RetryTimes = 2 TypeError = '-' TypeSimpleString = '+' TypeBulkString = '$' TypeIntegers = ':' TypeArrays = '*' )
View Source
const ( DefaultMaxConnNumber = 100 DefaultMaxIdleNumber = 25 DefaultMaxIdleSeconds = 28 DefaultMaxConnsWaitTimes = 50 )
Variables ¶
View Source
var ( ErrNil = errors.New("nil data return") ErrBadType = errors.New("invalid return type") ErrBadTcpConn = errors.New("invalid tcp conn") ErrBadTerminator = errors.New("invalid terminator") ErrResponse = errors.New("bad call") ErrNilPool = errors.New("conn not belongs to any pool") ErrKeyNotExist = errors.New(CommonErrPrefix + "key not exist") ErrBadArgs = errors.New(CommonErrPrefix + "request args invalid") ErrEmptyDB = errors.New(CommonErrPrefix + "empty db") ErrResponseType = errors.New(CommonErrPrefix + "response type error") CommonErrPrefix = "CommonError:" )
Functions ¶
Types ¶
type Conn ¶
func Dial ¶
func Dial(address, password string, connectTimeout, readTimeout, writeTimeout time.Duration, keepAlive bool, pool *Pool) (*Conn, error)
connect with timeout
func (*Conn) BRPOPLPUSH ¶
func (*Conn) EVAL ¶
func (c *Conn) EVAL(script string, numkeys int, keys []string, scriptArgs []string) (interface{}, error)
****************** scripting ******************
func (*Conn) HGETALLMAP ¶
返回结果用map组织
func (*Conn) HINCRBYFLOAT ¶
func (*Conn) MIGRATE ¶
func (c *Conn) MIGRATE(host, port, key, destDB string, timeout int, COPY, REPLACE bool) (bool, error)
since 2.6.0 COPY and REPLACE will be available in 3.0
func (*Conn) SCRIPTEXISTS ¶
func (*Conn) SCRIPTFLUSH ¶
func (*Conn) SCRIPTKILL ¶
func (*Conn) ZINTERSTORE ¶
func (*Conn) ZRANGEBYSCORE ¶
func (*Conn) ZREMRANGEBYRANK ¶
func (*Conn) ZREMRANGEBYSCORE ¶
func (*Conn) ZREVRANGEBYSCORE ¶
type MultiPool ¶
type MultiPool struct {
// contains filtered or unexported fields
}
include multi redis server's connection pool
func NewMultiPool ¶
func (*MultiPool) PushByAddr ¶
type Pool ¶
type Pool struct { Address string Password string // 统计信息 IdleNum int ActiveNum int MaxConnNum int MaxIdleNum int CreateNum int CreateFailedNum int WaitTimeoutNum int PingErrNum int CallNetErrNum int MaxIdleSeconds int64 ClientPool chan *Conn CallNum int64 ScriptMap map[string]string CallConsume map[string]int // 命令消耗时长 // contains filtered or unexported fields }
connection pool of only one redis server
func (*Pool) AddScriptSha1 ¶
func (*Pool) DelScriptSha1 ¶
func (*Pool) GetScriptSha1 ¶
Click to show internal directories.
Click to hide internal directories.