Documentation
¶
Overview ¶
package redis implements a client for Redis with support for all commands and features such as transactions and pubsub.
Index ¶
- Variables
- type Client
- func (c *Client) Append(key string, value interface{}) (int64, error)
- func (c *Client) Bgrewriteaof() error
- func (c *Client) Bgsave() error
- func (c *Client) Blpop(keys []string, timeout int64) (*Reply, error)
- func (c *Client) Brpop(keys []string, timeout int64) (*Reply, error)
- func (c *Client) Brpoplpush(source string, destination string, timeout int64) (Elem, error)
- func (c *Client) ConfigGet(parameter string) (*Reply, error)
- func (c *Client) ConfigResetstat() error
- func (c *Client) ConfigSet(parameter string, value string) error
- func (c *Client) Dbsize() (int64, error)
- func (c *Client) DebugObject(key string) (Elem, error)
- func (c *Client) DebugSegfault() error
- func (c *Client) Decr(key string) (int64, error)
- func (c *Client) Decrby(key string, decrement int64) (int64, error)
- func (c *Client) Del(keys ...string) (int64, error)
- func (c *Client) Echo(message interface{}) (Elem, error)
- func (c *Client) Exists(key string) (bool, error)
- func (c *Client) Expire(key string, seconds int64) (bool, error)
- func (c *Client) Expireat(key string, timestamp int64) (bool, error)
- func (c *Client) Flushall() error
- func (c *Client) Flushdb() error
- func (c *Client) Get(key string) (Elem, error)
- func (c *Client) Getbit(key string, offset int) (int64, error)
- func (c *Client) Getrange(key string, start int, end int) (Elem, error)
- func (c *Client) Getset(key string, value interface{}) (Elem, error)
- func (c *Client) Hdel(key string, field string) (bool, error)
- func (c *Client) Hexists(key string, field string) (bool, error)
- func (c *Client) Hget(key string, field string) (Elem, error)
- func (c *Client) Hgetall(key string) (*Reply, error)
- func (c *Client) Hincrby(key string, field string, increment int64) (int64, error)
- func (c *Client) Hkeys(key string) ([]string, error)
- func (c *Client) Hlen(key string) (int64, error)
- func (c *Client) Hmget(key string, fields ...string) (*Reply, error)
- func (c *Client) Hmset(key string, mapping map[string]interface{}) error
- func (c *Client) Hset(key string, field string, value interface{}) (bool, error)
- func (c *Client) Hsetnx(key string, field string, value interface{}) (bool, error)
- func (c *Client) Hvals(key string) (*Reply, error)
- func (c *Client) Incr(key string) (int64, error)
- func (c *Client) Incrby(key string, increment int64) (int64, error)
- func (c *Client) Info() (Elem, error)
- func (c *Client) Keys(pattern string) ([]string, error)
- func (c *Client) Lastsave() (int64, error)
- func (c *Client) Lindex(key string, index int) (Elem, error)
- func (c *Client) Linsert(key, where string, pivot, value interface{}) (int64, error)
- func (c *Client) Llen(key string) (int64, error)
- func (c *Client) Lpop(key string) (Elem, error)
- func (c *Client) Lpush(key string, value interface{}) (int64, error)
- func (c *Client) Lpushx(key string, value interface{}) (int64, error)
- func (c *Client) Lrange(key string, start, stop int) (*Reply, error)
- func (c *Client) Lrem(key string, count int, value interface{}) (int64, error)
- func (c *Client) Lset(key string, index int, value interface{}) error
- func (c *Client) Ltrim(key string, start int, stop int) error
- func (c *Client) Mget(keys ...string) (*Reply, error)
- func (c *Client) Monitor() (*Reply, error)
- func (c *Client) Move(key string, db int) (bool, error)
- func (c *Client) Mset(mapping map[string]string) error
- func (c *Client) Msetnx(mapping map[string]string) (bool, error)
- func (c *Client) Persist(key string) (bool, error)
- func (c *Client) Ping() (Elem, error)
- func (c *Client) Psubscribe(patterns ...string) (*Sub, error)
- func (c *Client) Publish(channel string, message interface{}) (int64, error)
- func (c *Client) Quit() error
- func (c *Client) Randomkey() (string, error)
- func (c *Client) Rename(key string, newkey string) error
- func (c *Client) Renamenx(key string, newkey string) (bool, error)
- func (c *Client) Rpop(key string) (Elem, error)
- func (c *Client) Rpoplpush(source string, destination string) (Elem, error)
- func (c *Client) Rpush(key string, value interface{}) (int64, error)
- func (c *Client) Rpushx(key string, value interface{}) (int64, error)
- func (c *Client) Sadd(key string, member interface{}) (bool, error)
- func (c *Client) Save() error
- func (c *Client) Scard(key string) (int64, error)
- func (c *Client) Sdiff(keys ...string) (*Reply, error)
- func (c *Client) Sdiffstore(destination string, keys ...string) (int64, error)
- func (c *Client) Select(index int) error
- func (c *Client) Set(key string, value interface{}) error
- func (c *Client) Setbit(key string, offset int, value int) (int64, error)
- func (c *Client) Setex(key string, seconds int64, value interface{}) error
- func (c *Client) Setnx(key string, value interface{}) (bool, error)
- func (c *Client) Setrange(key string, offset int, value interface{}) (int64, error)
- func (c *Client) Shutdown() error
- func (c *Client) Sinter(keys ...string) (*Reply, error)
- func (c *Client) Sinterstore(destination string, keys ...string) (int64, error)
- func (c *Client) Sismember(key string, member interface{}) (bool, error)
- func (c *Client) Slaveof(host string, port string) error
- func (c *Client) Smembers(key string) (*Reply, error)
- func (c *Client) Smove(source string, destination string, member interface{}) (bool, error)
- func (c *Client) Sort(key string, args ...string) (*Reply, error)
- func (c *Client) Spop(key string) (Elem, error)
- func (c *Client) Srandmember(key string) (Elem, error)
- func (c *Client) Srem(key string, member interface{}) (bool, error)
- func (c *Client) Strlen(key string) (int64, error)
- func (c *Client) Subscribe(channels ...string) (*Sub, error)
- func (c *Client) Sunion(keys ...string) (*Reply, error)
- func (c *Client) Sunionstore(destination string, keys ...string) (int64, error)
- func (c *Client) Ttl(key string) (int64, error)
- func (c *Client) Type(key string) (string, error)
- func (c *Client) Zadd(key string, score float64, member interface{}) (bool, error)
- func (c *Client) Zcard(key string) (int64, error)
- func (c *Client) Zcount(key string, min float64, max float64) (int64, error)
- func (c *Client) Zincrby(key string, increment float64, member interface{}) (float64, error)
- func (c *Client) Zinterstore(destination string, keys []string, args ...string) (int64, error)
- func (c *Client) Zrange(key string, start int, stop int) (*Reply, error)
- func (c *Client) Zrangebyscore(key string, min string, max string, args ...string) (*Reply, error)
- func (c *Client) Zrank(key string, member interface{}) (int64, error)
- func (c *Client) Zrem(key string, member interface{}) (bool, error)
- func (c *Client) Zremrangebyrank(key string, start int, stop int) (int64, error)
- func (c *Client) Zremrangebyscore(key string, min float64, max float64) (int64, error)
- func (c *Client) Zrevrange(key string, start int, stop int, args ...string) (*Reply, error)
- func (c *Client) Zrevrangebyscore(key string, max float64, min float64, args ...string) (*Reply, error)
- func (c *Client) Zrevrank(key string, member interface{}) (int64, error)
- func (c *Client) Zscore(key string, member interface{}) (float64, error)
- func (c *Client) Zunionstore(destination string, keys []string, args ...string) (int64, error)
- type Elem
- type Message
- type Pipe
- type PipeClient
- type ReaderWriter
- type Reply
- type Sub
- type Sync
Constants ¶
This section is empty.
Variables ¶
var (
// Max connection pool size
MaxClientConn = 2
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Rw ReaderWriter
}
func New ¶
Returns a new Client given a net address, db and password. nettaddr should be formatted using "net:addr", where ":" is acting as a separator. E.g. "unix:/path/to/redis.sock", "tcp:127.0.0.1:12345". Use an empty string for redis defaults.
func (*Client) Bgrewriteaof ¶
Asynchronously rewrite the append-only file
func (*Client) Blpop ¶
Remove and get the first element in a list, or block until one is available If timeout expires an error is returned errors.New("timeout expired")
func (*Client) Brpop ¶
Remove and get the last element in a list, or block until one is available If timeout expires an error is returned errors.New("timeout expired")
func (*Client) Brpoplpush ¶
Pop a value from a list, push it to another list and return it; or block until one is available If timeout expires an error is returned errors.New("timeout expired")
func (*Client) ConfigResetstat ¶
Reset the stats returned by INFO
func (*Client) DebugObject ¶
Get debugging information about a key
func (*Client) Psubscribe ¶
Listen for messages published to channels matching the given patterns
func (*Client) Rpoplpush ¶
Remove the last element in a list, append it to another list and return it
func (*Client) Sdiffstore ¶
Subtract multiple sets and store the resulting set in a key
func (*Client) Sinterstore ¶
Intersect multiple sets and store the resulting set in a key
func (*Client) Srandmember ¶
Get a random member from a set
func (*Client) Sunionstore ¶
Add multiple sets and store the resulting set in a key
func (*Client) Zinterstore ¶
Intersect multiple sorted sets and store the resulting sorted set in a new key `numkeys` is determined by the len of `keys` param
func (*Client) Zrange ¶
Return a range of members in a sorted set, by index TODO: add WITHSCORES keyword
func (*Client) Zrangebyscore ¶
Return a range of members in a sorted set, by score
func (*Client) Zrank ¶
Determine the index of a member in a sorted set TODO: should cast an error when member does not exist
func (*Client) Zrem ¶
Remove a member from a sorted set TODO: Remove one or more members from a sorted set
func (*Client) Zremrangebyrank ¶
Remove all members in a sorted set within the given indexes
func (*Client) Zremrangebyscore ¶
Remove all members in a sorted set within the given scores
func (*Client) Zrevrange ¶
Return a range of members in a sorted set, by index, with scores ordered from high to low
func (*Client) Zrevrangebyscore ¶
func (c *Client) Zrevrangebyscore(key string, max float64, min float64, args ...string) (*Reply, error)
Return a range of members in a sorted set, by score, with scores ordered from high to low
func (*Client) Zrevrank ¶
Determine the index of a member in a sorted set, with scores ordered from high to low
type PipeClient ¶
type PipeClient struct {
*Client
}
func NewPipeClient ¶
func NewPipeClient(netaddr string, db int, password string) *PipeClient
PipeClient include support for MULTI/EXEC operations. It implements Exec() which executes all buffered commands. Set transaction to true to wrap buffered commands inside MULTI .. EXEC block. PipeClient is not thread-safe.
func NewPipeClientFromClient ¶
func NewPipeClientFromClient(c *Client) *PipeClient
Uses the connection settings from a existing client to create a new PipeClient
func (*PipeClient) Exec ¶
func (pc *PipeClient) Exec() []*Reply
Execute all commands issued after EXEC or buffered in the current pipe. Returns a slice of Replies.
func (*PipeClient) Multi ¶
func (pc *PipeClient) Multi() error
Mark the start of a transaction block
func (*PipeClient) Watch ¶
func (pc *PipeClient) Watch(keys ...string) error
Watch the given keys to determine execution of the MULTI/EXEC block
type ReaderWriter ¶
type ReaderWriter interface {
// contains filtered or unexported methods
}
type Reply ¶
func Send ¶
func Send(rw ReaderWriter, args ...[]byte) *Reply
writes a command a and returns single the Reply object
func SendIface ¶
func SendIface(rw ReaderWriter, name string, args ...interface{}) *Reply
uses reflection to create a bytestring of the name and args parameters, then calls Send()
func SendStr ¶
func SendStr(rw ReaderWriter, name string, args ...string) *Reply
creates a bytestring of the name and args parameters, then calls Send()
func (*Reply) BytesArray ¶
func (*Reply) StringArray ¶
type Sub ¶
type Sub struct { Messages chan *Message // contains filtered or unexported fields }
func (*Sub) Psubscribe ¶
Listen for messages published to channels matching the given patterns
func (*Sub) Punsubscribe ¶
Stop listening for messages posted to channels matching the given patterns
func (*Sub) Unsubscribe ¶
Stop listening for messages posted to the given channels