redis: menteslibres.net/gosexy/redis Index | Files

package redis

import "menteslibres.net/gosexy/redis"

The `redis` package is yet another Go client library for redis-server.

Index

Package Files

commands.go conn.go main.go

Constants

const (
    // Default port for connecting to redis-server.
    DefaultPort = 6379
)

Variables

var (
    ErrNilReply        = errors.New(`Received a nil response.`)
    ErrNotConnected    = errors.New(`Client is not connected.`)
    ErrExpectingPairs  = errors.New(`Expecting (field -> value) pairs.`)
    ErrNotInitialized  = errors.New(`Client is not initialized. Forgot to use redis.New()?`)
    ErrUnknownResponse = errors.New(`Unknown response.`)
    ErrNotEnoughData   = errors.New(`Not enough data.`)
)

Error messages

type Client

type Client struct {
    // contains filtered or unexported fields
}

A redis client

func New

func New() *Client

func (*Client) Append

func (c *Client) Append(key string, value interface{}) (int64, error)

If key already exists and is a string, this command appends the value at the end of the string. If key does not exist it is created and set as an empty string, so APPEND will be similar to SET in this special case.

http://redis.io/commands/append

func (*Client) Auth

func (c *Client) Auth(password string) (string, error)

Request for authentication in a password-protected Redis server. Redis can be instructed to require a password before allowing clients to execute commands. This is done using the requirepass directive in the configuration file.

http://redis.io/commands/auth

func (*Client) BLPop

func (c *Client) BLPop(timeout uint64, keys ...string) ([]string, error)

BLPOP is a blocking list pop primitive. It is the blocking version of LPOP because it blocks the connection when there are no elements to pop from any of the given lists. An element is popped from the head of the first list that is non-empty, with the given keys being checked in the order that they are given.

http://redis.io/commands/blpop

func (*Client) BRPop

func (c *Client) BRPop(timeout uint64, keys ...string) ([]string, error)

BRPOP is a blocking list pop primitive. It is the blocking version of RPOP because it blocks the connection when there are no elements to pop from any of the given lists. An element is popped from the tail of the first list that is non-empty, with the given keys being checked in the order that they are given.

http://redis.io/commands/brpop

func (*Client) BRPopLPush

func (c *Client) BRPopLPush(source string, destination string, timeout int64) (string, error)

BRPOPLPUSH is the blocking variant of RPOPLPUSH. When source contains elements, this command behaves exactly like RPOPLPUSH. When source is empty, Redis will block the connection until another client pushes to it or until timeout is reached. A timeout of zero can be used to block indefinitely.

http://redis.io/commands/brpoplpush

func (*Client) BgRewriteAOF

func (c *Client) BgRewriteAOF() (string, error)

Instruct Redis to start an Append Only File rewrite process. The rewrite will create a small optimized version of the current Append Only File.

http://redis.io/commands/bgwriteaof

func (*Client) BgSave

func (c *Client) BgSave() (string, error)

Save the DB in background. The OK code is immediately returned. Redis forks, the parent continues to serve the clients, the child saves the DB on disk then exits.

A client my be able to check if the operation succeeded using the LASTSAVE command.

http://redis.io/commands/bgsave

func (*Client) BitCount

func (c *Client) BitCount(key string, params ...int64) (int64, error)

Count the number of set bits (population counting) in a string.

http://redis.io/commands/bitcount

func (*Client) BitOp

func (c *Client) BitOp(op string, dest string, keys ...string) (int64, error)

Perform a bitwise operation between multiple keys (containing string values) and store the result in the destination key.

http://redis.io/commands/bitop

func (*Client) ClientGetName

func (c *Client) ClientGetName() (string, error)

The CLIENT GETNAME returns the name of the current connection as set by CLIENT SETNAME. Since every new connection starts without an associated name, if no name was assigned a null bulk reply is returned.

http://redis.io/commands/client-getname

func (*Client) ClientKill

func (c *Client) ClientKill(ip string, port uint) (string, error)

The CLIENT KILL command closes a given client connection identified by ip:port.

http://redis.io/commands/client-kill

func (*Client) ClientList

func (c *Client) ClientList() ([]string, error)

The CLIENT LIST command returns information and statistics about the client connections server in a mostly human readable format.

http://redis.io/commands/client-list

func (*Client) ClientSetName

func (c *Client) ClientSetName(connectionName string) (string, error)

The CLIENT SETNAME command assigns a name to the current connection.

http://redis.io/commands/client-setname

func (*Client) Close

func (c *Client) Close() error

func (*Client) Command

func (c *Client) Command(dest interface{}, values ...interface{}) error

Command builds a command specified by the `values` interface and stores the result into the variable pointed by `dest`.

func (*Client) ConfigGet

func (c *Client) ConfigGet(parameter string) (string, error)

The CONFIG GET command is used to read the configuration parameters of a running Redis server. Not all the configuration parameters are supported in Redis 2.4, while Redis 2.6 can read the whole configuration of a server using this command.

http://redis.io/commands/config-get

func (*Client) ConfigResetStat

func (c *Client) ConfigResetStat() (string, error)

Resets the statistics reported by Redis using the INFO command.

http://redis.io/commands/config-resetstat

func (*Client) ConfigSet

func (c *Client) ConfigSet(parameter string, value interface{}) (string, error)

The CONFIG SET command is used in order to reconfigure the server at run time without the need to restart Redis. You can change both trivial parameters or switch from one to another persistence option using this command.

http://redis.io/commands/config-set

func (*Client) Connect

func (c *Client) Connect(host string, port uint) (err error)

Connects the client to the given host and port.

func (*Client) ConnectNonBlock

func (c *Client) ConnectNonBlock(host string, port uint) error

ConnectNonBlock connects the client to the given host and port (deprecated).

func (*Client) ConnectUnix

func (c *Client) ConnectUnix(path string) error

ConnectUnix attempts to create a connection with a UNIX socket.

func (*Client) ConnectUnixNonBlock

func (c *Client) ConnectUnixNonBlock(path string) error

ConnectUnixNonBlock attempts to create a non-blocking connection with an UNIX socket (deprecated).

func (*Client) ConnectUnixWithTimeout

func (c *Client) ConnectUnixWithTimeout(path string, timeout time.Duration) error

ConnectUnixWithTimeout attempts to create a connection with an UNIX socket, giving up after the specified time.

func (*Client) ConnectWithTimeout

func (c *Client) ConnectWithTimeout(host string, port uint, timeout time.Duration) error

ConnectWithTimeout attempts to connect to a redis-server, giving up after the specified time.

func (*Client) DbSize

func (c *Client) DbSize() (uint64, error)

Return the number of keys in the currently-selected database.

http://redis.io/commands/dbsize

func (*Client) DebugObject

func (c *Client) DebugObject(key string) (string, error)

DEBUG OBJECT is a debugging command that should not be used by clients. Check the OBJECT command instead.

http://redis.io/commands/debug-object

func (*Client) DebugSegfault

func (c *Client) DebugSegfault() (string, error)

DEBUG SEGFAULT performs an invalid memory access that crashes Redis. It is used to simulate bugs during the development.

http://redis.io/commands/debug-segfault

func (*Client) Decr

func (c *Client) Decr(key string) (int64, error)

Decrements the number stored at key by one. If the key does not exist, it is set to 0 before performing the operation. An error is returned if the key contains a value of the wrong type or contains a string that can not be represented as integer. This operation is limited to 64 bit signed integers.

http://redis.io/commands/decr

func (*Client) DecrBy

func (c *Client) DecrBy(key string, decrement int64) (int64, error)

Decrements the number stored at key by decrement. If the key does not exist, it is set to 0 before performing the operation. An error is returned if the key contains a value of the wrong type or contains a string that can not be represented as integer. This operation is limited to 64 bit signed integers.

http://redis.io/commands/decrby

func (*Client) Del

func (c *Client) Del(keys ...string) (int64, error)

func (*Client) Discard

func (c *Client) Discard() (string, error)

Flushes all previously queued commands in a transaction and restores the connection state to normal.

http://redis.io/commands/discard

func (*Client) Dump

func (c *Client) Dump(key string) (string, error)

Serialize the value stored at key in a Redis-specific format and return it to the user. The returned value can be synthesized back into a Redis key using the RESTORE command.

http://redis.io/commands/dump

func (*Client) Echo

func (c *Client) Echo(message interface{}) (string, error)

Returns message.

http://redis.io/commands/echo

func (*Client) Eval

func (c *Client) Eval(script string, numkeys int64, arguments ...interface{}) ([]string, error)

EVAL and EVALSHA are used to evaluate scripts using the Lua interpreter built into Redis starting from version 2.6.0.

http://redis.io/commands/eval

func (*Client) EvalSHA

func (c *Client) EvalSHA(hash string, numkeys int64, arguments ...interface{}) ([]string, error)

Evaluates a script cached on the server side by its SHA1 digest. Scripts are cached on the server side using the SCRIPT LOAD command. The command is otherwise identical to EVAL.

http://redis.io/commands/evalsha

func (*Client) Exec

func (c *Client) Exec() ([]interface{}, error)

Executes all previously queued commands in a transaction and restores the connection state to normal.

http://redis.io/commands/exec

func (*Client) Exists

func (c *Client) Exists(key string) (bool, error)

Returns if key exists.

http://redis.io/commands/exists

func (*Client) Expire

func (c *Client) Expire(key string, seconds uint64) (bool, error)

Set a timeout on key. After the timeout has expired, the key will automatically be deleted. A key with an associated timeout is often said to be volatile in Redis terminology.

http://redis.io/commands/expire

func (*Client) ExpireAt

func (c *Client) ExpireAt(key string, unixTime uint64) (bool, error)

EXPIREAT has the same effect and semantic as EXPIRE, but instead of specifying the number of seconds representing the TTL (time to live), it takes an absolute Unix timestamp (seconds since January 1, 1970).

http://redis.io/commands/expireat

func (*Client) FlushAll

func (c *Client) FlushAll() (string, error)

Delete all the keys of all the existing databases, not just the currently selected one. This command never fails.

http://redis.io/commands/flushall

func (*Client) FlushDB

func (c *Client) FlushDB() (string, error)

Delete all the keys of the currently selected DB. This command never fails.

http://redis.io/commands/flushdb

func (*Client) Get

func (c *Client) Get(key string) (string, error)

Get the value of key. If the key does not exist the special value nil is returned. An error is returned if the value stored at key is not a string, because GET only handles string values.

http://redis.io/commands/get

func (*Client) GetBit

func (c *Client) GetBit(key string, offset int64) (int64, error)

Returns the bit value at offset in the string value stored at key.

http://redis.io/commands/getbit

func (*Client) GetRange

func (c *Client) GetRange(key string, start int64, end int64) (string, error)

Returns the substring of the string value stored at key, determined by the offsets start and end (both are inclusive). Negative offsets can be used in order to provide an offset starting from the end of the string. So -1 means the last character, -2 the penultimate and so forth.

http://redis.io/commands/getrange

func (*Client) GetSet

func (c *Client) GetSet(key string, value interface{}) (string, error)

Atomically sets key to value and returns the old value stored at key. Returns an error when key exists but does not hold a string value.

http://redis.io/commands/getset

func (*Client) HDel

func (c *Client) HDel(key string, fields ...string) (int64, error)

Removes the specified fields from the hash stored at key. Specified fields that do not exist within this hash are ignored. If key does not exist, it is treated as an empty hash and this command returns 0.

http://redis.io/commands/hdel

func (*Client) HExists

func (c *Client) HExists(key string, field string) (bool, error)

Returns if field is an existing field in the hash stored at key.

http://redis.io/commands/hexists

func (*Client) HGet

func (c *Client) HGet(key string, field string) (string, error)

Returns the value associated with field in the hash stored at key.

http://redis.io/commands/hget

func (*Client) HGetAll

func (c *Client) HGetAll(key string) ([]string, error)

Returns all fields and values of the hash stored at key. In the returned value, every field name is followed by its value, so the length of the reply is twice the size of the hash.

http://redis.io/commands/hgetall

func (*Client) HIncrBy

func (c *Client) HIncrBy(key string, field string, increment interface{}) (int64, error)

Increments the number stored at field in the hash stored at key by increment. If key does not exist, a new key holding a hash is created. If field does not exist the value is set to 0 before the operation is performed.

http://redis.io/commands/hincrby

func (*Client) HIncrByFloat

func (c *Client) HIncrByFloat(key string, field string, increment float64) (string, error)

Increment the specified field of an hash stored at key, and representing a floating point number, by the specified increment. If the field does not exist, it is set to 0 before performing the operation.

http://redis.io/commands/hincrbyfloat

func (*Client) HKeys

func (c *Client) HKeys(key string) ([]string, error)

Returns all field names in the hash stored at key.

http://redis.io/commands/hkeys

func (*Client) HLen

func (c *Client) HLen(key string) (int64, error)

Returns the number of fields contained in the hash stored at key.

http://redis.io/commands/hlen

func (*Client) HMGet

func (c *Client) HMGet(key string, fields ...string) ([]string, error)

Returns the values associated with the specified fields in the hash stored at key.

http://redis.io/commands/hmget

func (*Client) HMSet

func (c *Client) HMSet(key string, values ...interface{}) (string, error)

Sets the specified fields to their respective values in the hash stored at key. This command overwrites any existing fields in the hash. If key does not exist, a new key holding a hash is created.

http://redis.io/commands/hmset

func (*Client) HScan

func (c *Client) HScan(cursor int64, arguments ...interface{}) ([]string, error)

HSCAN iterates fields of Hash types and their associated values.

http://redis.io/commands/scan

func (*Client) HSet

func (c *Client) HSet(key string, field string, value interface{}) (bool, error)

Sets field in the hash stored at key to value. If key does not exist, a new key holding a hash is created. If field already exists in the hash, it is overwritten.

http://redis.io/commands/hset

func (*Client) HSetNX

func (c *Client) HSetNX(key string, field string, value interface{}) (bool, error)

Sets field in the hash stored at key to value, only if field does not yet exist. If key does not exist, a new key holding a hash is created. If field already exists, this operation has no effect.

http://redis.io/commands/hsetnx

func (*Client) HVals

func (c *Client) HVals(key string) ([]string, error)

Returns all values in the hash stored at key.

http://redis.io/commands/hvals

func (*Client) Incr

func (c *Client) Incr(key string) (int64, error)

Increments the number stored at key by one. If the key does not exist, it is set to 0 before performing the operation. An error is returned if the key contains a value of the wrong type or contains a string that can not be represented as integer. This operation is limited to 64 bit signed integers.

http://redis.io/commands/incr

func (*Client) IncrBy

func (c *Client) IncrBy(key string, increment int64) (int64, error)

Increments the number stored at key by increment. If the key does not exist, it is set to 0 before performing the operation. An error is returned if the key contains a value of the wrong type or contains a string that can not be represented as integer. This operation is limited to 64 bit signed integers.

http://redis.io/commands/incrby

func (*Client) IncrByFloat

func (c *Client) IncrByFloat(key string, increment float64) (string, error)

Increment the string representing a floating point number stored at key by the specified increment. If the key does not exist, it is set to 0 before performing the operation.

http://redis.io/commands/incrbyfloat

func (*Client) Info

func (c *Client) Info(section string) (ret string, err error)

The INFO command returns information and statistics about the server in a format that is simple to parse by computers and easy to read by humans.

http://redis.io/commands/info

func (*Client) Keys

func (c *Client) Keys(pattern string) ([]string, error)

Returns all keys matching pattern.

http://redis.io/commands/keys

func (*Client) LIndex

func (c *Client) LIndex(key string, index int64) (string, error)

Returns the element at index index in the list stored at key. The index is zero-based, so 0 means the first element, 1 the second element and so on. Negative indices can be used to designate elements starting at the tail of the list. Here, -1 means the last element, -2 means the penultimate and so forth.

http://redis.io/commands/lindex

func (*Client) LInsert

func (c *Client) LInsert(key string, where string, pivot interface{}, value interface{}) (int64, error)

Inserts value in the list stored at key either before or after the reference value pivot.

http://redis.io/commands/linsert

func (*Client) LLen

func (c *Client) LLen(key string) (int64, error)

Returns the length of the list stored at key. If key does not exist, it is interpreted as an empty list and 0 is returned. An error is returned when the value stored at key is not a list.

http://redis.io/commands/llen

func (*Client) LPop

func (c *Client) LPop(key string) (string, error)

Removes and returns the first element of the list stored at key.

http://redis.io/commands/lpop

func (*Client) LPush

func (c *Client) LPush(key string, values ...interface{}) (int64, error)

Insert all the specified values at the head of the list stored at key. If key does not exist, it is created as empty list before performing the push operations. When key holds a value that is not a list, an error is returned.

http://redis.io/commands/lpush

func (*Client) LPushX

func (c *Client) LPushX(key string, value interface{}) (int64, error)

Inserts value at the head of the list stored at key, only if key already exists and holds a list. In contrary to LPUSH, no operation will be performed when key does not yet exist.

http://redis.io/commands/lpushx

func (*Client) LRange

func (c *Client) LRange(key string, start int64, stop int64) ([]string, error)

Returns the specified elements of the list stored at key. The offsets start and stop are zero-based indexes, with 0 being the first element of the list (the head of the list), 1 being the next element and so on.

http://redis.io/commands/lrange

func (*Client) LRem

func (c *Client) LRem(key string, count int64, value interface{}) (int64, error)

Removes the first count occurrences of elements equal to value from the list stored at key. The count argument influences the operation in the following ways:

http://redis.io/commands/lrem

func (*Client) LSet

func (c *Client) LSet(key string, index int64, value interface{}) (string, error)

Sets the list element at index to value. For more information on the index argument, see LINDEX.

http://redis.io/commands/lset

func (*Client) LTrim

func (c *Client) LTrim(key string, start int64, stop int64) (string, error)

Trim an existing list so that it will contain only the specified range of elements specified. Both start and stop are zero-based indexes, where 0 is the first element of the list (the head), 1 the next element and so on.

http://redis.io/commands/ltrim

func (*Client) LastSave

func (c *Client) LastSave() (int64, error)

Return the UNIX TIME of the last DB save executed with success.

http://redis.io/commands/lastsave

func (*Client) MGet

func (c *Client) MGet(keys ...string) ([]string, error)

Returns the values of all specified keys. For every key that does not hold a string value or does not exist, the special value nil is returned. Because of this, the operation never fails.

func (*Client) MSet

func (c *Client) MSet(values ...interface{}) (string, error)

Sets the given keys to their respective values. MSET replaces existing values with new values, just as regular SET. See MSETNX if you don't want to overwrite existing values.

http://redis.io/commands/mset

func (*Client) MSetNX

func (c *Client) MSetNX(values ...interface{}) (bool, error)

Sets the given keys to their respective values. MSETNX will not perform any operation at all even if just a single key already exists.

http://redis.io/commands/msetnx

func (*Client) Migrate

func (c *Client) Migrate(host string, port uint, key string, destination string, timeout int64) (string, error)

Atomically transfer a key from a source Redis instance to a destination Redis instance. On success the key is deleted from the original instance and is guaranteed to exist in the target instance.

http://redis.io/commands/migrate

func (*Client) Move

func (c *Client) Move(key string, db string) (bool, error)

Move key from the currently selected database (see SELECT) to the specified destination database. When key already exists in the destination database, or it does not exist in the source database, it does nothing. It is possible to use MOVE as a locking primitive because of this.

http://redis.io/commands/move

func (*Client) Multi

func (c *Client) Multi() (string, error)

Marks the start of a transaction block. Subsequent commands will be queued for atomic execution using EXEC.

http://redis.io/commands/multi

func (*Client) Object

func (c *Client) Object(subcommand string, arguments ...interface{}) (string, error)

The OBJECT command allows to inspect the internals of Redis Objects associated with keys. It is useful for debugging or to understand if your keys are using the specially encoded data types to save space. Your application may also use the information reported by the OBJECT command to implement application level key eviction policies when using Redis as a Cache.

http://redis.io/commands/object

func (*Client) PExpire

func (c *Client) PExpire(key string, milliseconds int64) (bool, error)

This command works exactly like EXPIRE but the time to live of the key is specified in milliseconds instead of seconds.

http://redis.io/commands/pexpire

func (*Client) PExpireAt

func (c *Client) PExpireAt(key string, milliseconds int64) (bool, error)

PEXPIREAT has the same effect and semantic as EXPIREAT, but the Unix time at which the key will expire is specified in milliseconds instead of seconds.

http://redis.io/commands/pexpireat

func (*Client) PSetEx

func (c *Client) PSetEx(key string, milliseconds int64, value interface{}) (string, error)

PSETEX works exactly like SETEX with the sole difference that the expire time is specified in milliseconds instead of seconds.

http://redis.io/commands/psetex

func (*Client) PSubscribe

func (c *Client) PSubscribe(cn chan []string, channel ...string) error

Subscribes the client to the given patterns.

http://redis.io/commands/psubscribe

func (*Client) PTTL

func (c *Client) PTTL(key string) (int64, error)

Like TTL this command returns the remaining time to live of a key that has an expire set, with the sole difference that TTL returns the amount of remaining time in seconds while PTTL returns it in milliseconds.

http://redis.io/commands/pttl

func (*Client) PUnsubscribe

func (c *Client) PUnsubscribe(pattern ...string) error

Unsubscribes the client from the given patterns, or from all of them if none is given.

http://redis.io/commands/punsubscribe

func (*Client) Persist

func (c *Client) Persist(key string) (bool, error)

Remove the existing timeout on key, turning the key from volatile (a key with an expire set) to persistent (a key that will never expire as no timeout is associated).

http://redis.io/commands/persist

func (*Client) Ping

func (c *Client) Ping() (ret string, err error)

Ping() Returns PONG. This command is often used to test if a connection is still alive, or to measure latency.

Reference: http://redis.io/commands/ping

func (*Client) PubSub

func (c *Client) PubSub(subcommand string, arguments ...interface{}) ([]string, error)

The PUBSUB command is an introspection command that allows to inspect the state of the Pub/Sub subsystem. It is composed of subcommands that are documented separately.

http://redis.io/commands/pubsub

func (*Client) Publish

func (c *Client) Publish(channel string, message interface{}) (int64, error)

Posts a message to the given channel.

http://redis.io/commands/publish

func (*Client) Quit

func (c *Client) Quit() (s string, err error)

Ask the server to close the connection. The connection is closed as soon as all pending replies have been written to the client.

http://redis.io/commands/quit

func (*Client) RPop

func (c *Client) RPop(key string) (string, error)

Removes and returns the last element of the list stored at key.

http://redis.io/commands/restore

func (*Client) RPopLPush

func (c *Client) RPopLPush(source string, destination string) (string, error)

Atomically returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at destination.

http://redis.io/commands/rpoplpush

func (*Client) RPush

func (c *Client) RPush(key string, values ...interface{}) (int64, error)

Insert all the specified values at the tail of the list stored at key. If key does not exist, it is created as empty list before performing the push operation. When key holds a value that is not a list, an error is returned.

http://redis.io/commands/rpush

func (*Client) RPushX

func (c *Client) RPushX(key string, value interface{}) (int64, error)

Inserts value at the tail of the list stored at key, only if key already exists and holds a list. In contrary to RPUSH, no operation will be performed when key does not yet exist.

http://redis.io/commands/rpushx

func (*Client) RandomKey

func (c *Client) RandomKey() (string, error)

Return a random key from the currently selected database.

http://redis.io/commands/randomkey

func (*Client) Rename

func (c *Client) Rename(key string, newkey string) (string, error)

Renames key to newkey. It returns an error when the source and destination names are the same, or when key does not exist. If newkey already exists it is overwritten.

http://redis.io/commands/rename

func (*Client) RenameNX

func (c *Client) RenameNX(key string, newkey string) (bool, error)

Renames key to newkey if newkey does not yet exist. It returns an error under the same conditions as RENAME.

http://redis.io/commands/renamenx

func (*Client) Restore

func (c *Client) Restore(key string, ttl int64, serializedValue string) (string, error)

Create a key associated with a value that is obtained by deserializing the provided serialized value (obtained via DUMP).

http://redis.io/commands/restore

func (*Client) SAdd

func (c *Client) SAdd(key string, member ...interface{}) (int64, error)

Add the specified members to the set stored at key. Specified members that are already a member of this set are ignored. If key does not exist, a new set is created before adding the specified members.

http://redis.io/commands/sadd

func (*Client) SCard

func (c *Client) SCard(key string) (int64, error)

Returns the set cardinality (number of elements) of the set stored at key.

http://redis.io/commands/scard

func (*Client) SDiff

func (c *Client) SDiff(key ...string) ([]string, error)

Returns the members of the set resulting from the difference between the first set and all the successive sets.

http://redis.io/commands/sdiff

func (*Client) SDiffStore

func (c *Client) SDiffStore(destination string, key ...string) (int64, error)

This command is equal to SDIFF, but instead of returning the resulting set, it is stored in destination.

http://redis.io/commands/sdiffstore

func (*Client) SInter

func (c *Client) SInter(key ...string) ([]string, error)

Returns the members of the set resulting from the intersection of all the given sets.

http://redis.io/commands/sinter

func (*Client) SInterStore

func (c *Client) SInterStore(destination string, key ...string) (int64, error)

This command is equal to SINTER, but instead of returning the resulting set, it is stored in destination.

http://redis.io/commands/sinterstore

func (*Client) SIsMember

func (c *Client) SIsMember(key string, member interface{}) (bool, error)

Returns if member is a member of the set stored at key.

http://redis.io/commands/sismember

func (*Client) SMembers

func (c *Client) SMembers(key string) ([]string, error)

Returns all the members of the set value stored at key.

http://redis.io/commands/smembers

func (*Client) SMove

func (c *Client) SMove(source string, destination string, member interface{}) (bool, error)

Move member from the set at source to the set at destination. This operation is atomic. In every given moment the element will appear to be a member of source or destination for other clients.

http://redis.io/commands/smove

func (*Client) SPop

func (c *Client) SPop(key string) (string, error)

Removes and returns a random element from the set value stored at key.

http://redis.io/commands/spop

func (*Client) SRandMember

func (c *Client) SRandMember(key string, count int64) ([]string, error)

When called with just the key argument, return a random element from the set value stored at key.

http://redis.io/commands/srandmember

func (*Client) SRem

func (c *Client) SRem(key string, members ...interface{}) (int64, error)

Remove the specified members from the set stored at key. Specified members that are not a member of this set are ignored. If key does not exist, it is treated as an empty set and this command returns 0.

http://redis.io/commands/srem

func (*Client) SScan

func (c *Client) SScan(cursor int64, arguments ...interface{}) ([]string, error)

SSCAN iterates elements of Sets types.

http://redis.io/commands/scan

func (*Client) SUnion

func (c *Client) SUnion(key ...string) ([]string, error)

Returns the members of the set resulting from the union of all the given sets.

http://redis.io/commands/sunion

func (*Client) SUnionStore

func (c *Client) SUnionStore(destination string, key ...string) (int64, error)

This command is equal to SUNION, but instead of returning the resulting set, it is stored in destination.

http://redis.io/commands/sunionstore

func (*Client) Save

func (c *Client) Save() (string, error)

The SAVE commands performs a synchronous save of the dataset producing a point in time snapshot of all the data inside the Redis instance, in the form of an RDB file.

http://redis.io/commands/save

func (*Client) Scan

func (c *Client) Scan(cursor int64, arguments ...interface{}) ([]string, error)

SCAN iterates the set of keys in the currently selected Redis database.

http://redis.io/commands/scan

func (*Client) ScriptExists

func (c *Client) ScriptExists(script ...string) ([]string, error)

Returns information about the existence of the scripts in the script cache.

http://redis.io/commands/script-exists

func (*Client) ScriptFlush

func (c *Client) ScriptFlush() (string, error)

Flush the Lua scripts cache.

http://redis.io/commands/script-flush

func (*Client) ScriptKill

func (c *Client) ScriptKill() (string, error)

Kills the currently executing Lua script, assuming no write operation was yet performed by the script.

http://redis.io/commands/script-kill

func (*Client) ScriptLoad

func (c *Client) ScriptLoad(script string) (string, error)

Load a script into the scripts cache, without executing it. After the specified command is loaded into the script cache it will be callable using EVALSHA with the correct SHA1 digest of the script, exactly like after the first successful invocation of EVAL.

http://redis.io/commands/script-load

func (*Client) Select

func (c *Client) Select(index int64) (string, error)

Select the DB with having the specified zero-based numeric index. New connections always use DB 0.

http://redis.io/commands/select

func (*Client) Set

func (c *Client) Set(key string, value interface{}) (ret string, err error)

Set key to hold the string value. If key already holds a value, it is overwritten, regardless of its type.

http://redis.io/commands/set

func (*Client) SetBit

func (c *Client) SetBit(key string, offset int64, value int64) (int64, error)

Sets or clears the bit at offset in the string value stored at key.

http://redis.io/commands/setbit

func (*Client) SetEx

func (c *Client) SetEx(key string, seconds int64, value interface{}) (int, error)

Set key to hold the string value and set key to timeout after a given number of seconds. This command is equivalent to executing the following commands:

http://redis.io/commands/setex

func (*Client) SetNX

func (c *Client) SetNX(key string, value interface{}) (bool, error)

Set key to hold string value if key does not exist. In that case, it is equal to SET. When key already holds a value, no operation is performed. SETNX is short for "SET if N ot e X ists".

http://redis.io/commands/setnx

func (*Client) SetRange

func (c *Client) SetRange(key string, offset int64, value interface{}) (int64, error)

Overwrites part of the string stored at key, starting at the specified offset, for the entire length of value. If the offset is larger than the current length of the string at key, the string is padded with zero-bytes to make offset fit. Non-existing keys are considered as empty strings, so this command will make sure it holds a string large enough to be able to set value at offset.

http://redis.io/commands/setrange

func (*Client) SlaveOf

func (c *Client) SlaveOf(key string, port uint) (string, error)

The SLAVEOF command can change the replication settings of a slave on the fly. If a Redis server is already acting as slave, the command SLAVEOF NO ONE will turn off the replication, turning the Redis server into a MASTER. In the proper form SLAVEOF hostname port will make the server a slave of another server listening at the specified hostname and port.

http://redis.io/commands/slaveof

func (*Client) SlowLog

func (c *Client) SlowLog(subcommand string, argument interface{}) ([]string, error)

This command is used in order to read and reset the Redis slow queries log.

http://redis.io/commands/slowlog

func (*Client) Sort

func (c *Client) Sort(key string, arguments ...string) ([]string, error)

Returns or stores the elements contained in the list, set or sorted set at key. By default, sorting is numeric and elements are compared by their value interpreted as double precision floating point number.

http://redis.io/commands/sort

func (*Client) Strlen

func (c *Client) Strlen(key string) (int64, error)

Returns the length of the string value stored at key. An error is returned when key holds a non-string value.

http://redis.io/commands/strlen

func (*Client) Subscribe

func (c *Client) Subscribe(cn chan []string, channel ...string) error

Subscribes the client to the specified channels.

http://redis.io/commands/subscribe

func (*Client) Sync

func (c *Client) Sync() (string, error)

http://redis.io/commands/sync

func (*Client) TTL

func (c *Client) TTL(key string) (int64, error)

Returns the remaining time to live of a key that has a timeout. This introspection capability allows a Redis client to check how many seconds a given key will continue to be part of the dataset.

http://redis.io/commands/ttl

func (*Client) Time

func (c *Client) Time() ([]uint64, error)

The TIME command returns the current server time as a two items lists: a Unix timestamp and the amount of microseconds already elapsed in the current second. Basically the interface is very similar to the one of the gettimeofday system call.

http://redis.io/commands/time

func (*Client) Type

func (c *Client) Type(key string) (string, error)

Returns the string representation of the type of the value stored at key. The different types that can be returned are: string, list, set, zset and hash.

http://redis.io/commands/type

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(channel ...string) error

Unsubscribes the client from the given channels, or from all of them if none is given.

http://redis.io/commands/unsubscribe

func (*Client) Unwatch

func (c *Client) Unwatch() (string, error)

Flushes all the previously watched keys for a transaction.

http://redis.io/commands/unwatch

func (*Client) Watch

func (c *Client) Watch(key ...string) (string, error)

Marks the given keys to be watched for conditional execution of a transaction.

http://redis.io/commands/watch

func (*Client) ZAdd

func (c *Client) ZAdd(key string, arguments ...interface{}) (int64, error)

Adds all the specified members with the specified scores to the sorted set stored at key. It is possible to specify multiple score/member pairs. If a specified member is already a member of the sorted set, the score is updated and the element reinserted at the right position to ensure the correct ordering. If key does not exist, a new sorted set with the specified members as sole members is created, like if the sorted set was empty. If the key exists but does not hold a sorted set, an error is returned.

http://redis.io/commands/zadd

func (*Client) ZCard

func (c *Client) ZCard(key string) (int64, error)

Returns the sorted set cardinality (number of elements) of the sorted set stored at key.

http://redis.io/commands/zcard

func (*Client) ZCount

func (c *Client) ZCount(key string, min interface{}, max interface{}) (int64, error)

Returns the number of elements in the sorted set at key with a score between min and max.

http://redis.io/commands/zcount

func (*Client) ZIncrBy

func (c *Client) ZIncrBy(key string, increment int64, member interface{}) (string, error)

Increments the score of member in the sorted set stored at key by increment. If member does not exist in the sorted set, it is added with increment as its score (as if its previous score was 0.0). If key does not exist, a new sorted set with the specified member as its sole member is created.

http://redis.io/commands/zincrby

func (*Client) ZInterStore

func (c *Client) ZInterStore(destination string, numkeys int64, arguments ...interface{}) (int64, error)

Computes the intersection of numkeys sorted sets given by the specified keys, and stores the result in destination. It is mandatory to provide the number of input keys (numkeys) before passing the input keys and the other (optional) arguments.

http://redis.io/commands/zinterstore

func (*Client) ZRange

func (c *Client) ZRange(key string, values ...interface{}) ([]string, error)

Returns the specified range of elements in the sorted set stored at key. The elements are considered to be ordered from the lowest to the highest score. Lexicographical order is used for elements with equal score.

http://redis.io/commands/zrange

func (*Client) ZRangeByScore

func (c *Client) ZRangeByScore(key string, values ...interface{}) ([]string, error)

Returns all the elements in the sorted set at key with a score between min and max (including elements with score equal to min or max). The elements are considered to be ordered from low to high scores.

http://redis.io/commands/zrangebyscore

func (*Client) ZRank

func (c *Client) ZRank(key string, member interface{}) (int64, error)

Returns the rank of member in the sorted set stored at key, with the scores ordered from low to high. The rank (or index) is 0-based, which means that the member with the lowest score has rank 0.

http://redis.io/commands/zrank

func (*Client) ZRem

func (c *Client) ZRem(key string, arguments ...interface{}) (int64, error)

Removes the specified members from the sorted set stored at key. Non existing members are ignored.

http://redis.io/commands/zrem

func (*Client) ZRemRangeByRank

func (c *Client) ZRemRangeByRank(key string, start interface{}, stop interface{}) (int64, error)

Removes all elements in the sorted set stored at key with rank between start and stop. Both start and stop are 0 -based indexes with 0 being the element with the lowest score. These indexes can be negative numbers, where they indicate offsets starting at the element with the highest score. For example: -1 is the element with the highest score, -2 the element with the second highest score and so forth.

http://redis.io/commands/zremrangebyrank

func (*Client) ZRemRangeByScore

func (c *Client) ZRemRangeByScore(key string, min interface{}, max interface{}) (int64, error)

Removes all elements in the sorted set stored at key with a score between min and max (inclusive).

http://redis.io/commands/zremrangebyscore

func (*Client) ZRevRange

func (c *Client) ZRevRange(key string, start int64, stop int64, params ...interface{}) ([]string, error)

Returns the specified range of elements in the sorted set stored at key. The elements are considered to be ordered from the highest to the lowest score. Descending lexicographical order is used for elements with equal score.

http://redis.io/commands/zrevrange

func (*Client) ZRevRangeByScore

func (c *Client) ZRevRangeByScore(key string, start interface{}, stop interface{}, params ...interface{}) ([]string, error)

Returns all the elements in the sorted set at key with a score between max and min (including elements with score equal to max or min). In contrary to the default ordering of sorted sets, for this command the elements are considered to be ordered from high to low scores.

http://redis.io/commands/zrevrangebyscore

func (*Client) ZRevRank

func (c *Client) ZRevRank(key string, member interface{}) (int64, error)

Returns the rank of member in the sorted set stored at key, with the scores ordered from high to low. The rank (or index) is 0-based, which means that the member with the highest score has rank 0.

http://redis.io/commands/zrevrank

func (*Client) ZScan

func (c *Client) ZScan(cursor int64, arguments ...interface{}) ([]string, error)

ZSCAN iterates elements of Sorted Set types and their associated scores.

http://redis.io/commands/zscan

func (*Client) ZScore

func (c *Client) ZScore(key string, member interface{}) (int64, error)

Returns the score of member in the sorted set at key.

http://redis.io/commands/zscore

func (*Client) ZUnionStore

func (c *Client) ZUnionStore(destination string, numkeys int64, key string, params ...interface{}) (int64, error)

Computes the union of numkeys sorted sets given by the specified keys, and stores the result in destination. It is mandatory to provide the number of input keys (numkeys) before passing the input keys and the other (optional) arguments.

http://redis.io/commands/zunionstore

Package redis imports 10 packages (graph) and is imported by 5 packages. Updated 2014-10-17. Refresh now. Tools for package owners.