Documentation ¶
Overview ¶
The `redis` package is yet another Go client library for redis-server.
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) Append(key string, value interface{}) (int64, error)
- func (c *Client) Auth(password string) (string, error)
- func (c *Client) BLPop(timeout uint64, keys ...string) ([]string, error)
- func (c *Client) BRPop(timeout uint64, keys ...string) ([]string, error)
- func (c *Client) BRPopLPush(source string, destination string, timeout int64) (string, error)
- func (c *Client) BgRewriteAOF() (string, error)
- func (c *Client) BgSave() (string, error)
- func (c *Client) BitCount(key string, params ...int64) (int64, error)
- func (c *Client) BitOp(op string, dest string, keys ...string) (int64, error)
- func (c *Client) ClientGetName() (string, error)
- func (c *Client) ClientKill(ip string, port uint) (string, error)
- func (c *Client) ClientList() ([]string, error)
- func (c *Client) ClientSetName(connectionName string) (string, error)
- func (c *Client) Close() error
- func (c *Client) Command(dest interface{}, values ...interface{}) error
- func (c *Client) ConfigGet(parameter string) ([]string, error)
- func (c *Client) ConfigResetStat() (string, error)
- func (c *Client) ConfigSet(parameter string, value interface{}) (string, error)
- func (c *Client) Connect(host string, port uint) (err error)
- func (c *Client) ConnectNonBlock(host string, port uint) error
- func (c *Client) ConnectUnix(path string) error
- func (c *Client) ConnectUnixNonBlock(path string) error
- func (c *Client) ConnectUnixWithTimeout(path string, timeout time.Duration) error
- func (c *Client) ConnectWithTimeout(host string, port uint, timeout time.Duration) error
- func (c *Client) DbSize() (uint64, error)
- func (c *Client) DebugObject(key string) (string, error)
- func (c *Client) DebugSegfault() (string, 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) Discard() (string, error)
- func (c *Client) Dump(key string) (string, error)
- func (c *Client) Echo(message interface{}) (string, error)
- func (c *Client) Eval(script string, numkeys int64, arguments ...interface{}) ([]string, error)
- func (c *Client) EvalSHA(hash string, numkeys int64, arguments ...interface{}) ([]string, error)
- func (c *Client) Exec() ([]interface{}, error)
- func (c *Client) Exists(key string) (bool, error)
- func (c *Client) Expire(key string, seconds uint64) (bool, error)
- func (c *Client) ExpireAt(key string, unixTime uint64) (bool, error)
- func (c *Client) FlushAll() (string, error)
- func (c *Client) FlushDB() (string, error)
- func (c *Client) Get(key string) (string, error)
- func (c *Client) GetBit(key string, offset int64) (int64, error)
- func (c *Client) GetRange(key string, start int64, end int64) (string, error)
- func (c *Client) GetSet(key string, value interface{}) (string, error)
- func (c *Client) HDel(key string, fields ...string) (int64, error)
- func (c *Client) HExists(key string, field string) (bool, error)
- func (c *Client) HGet(key string, field string) (string, error)
- func (c *Client) HGetAll(key string) ([]string, error)
- func (c *Client) HIncrBy(key string, field string, increment interface{}) (int64, error)
- func (c *Client) HIncrByFloat(key string, field string, increment float64) (string, 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) ([]string, error)
- func (c *Client) HMSet(key string, values ...interface{}) (string, error)
- func (c *Client) HScan(key string, cursor int64, arguments ...interface{}) (ret []interface{}, err 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) ([]string, error)
- func (c *Client) Incr(key string) (int64, error)
- func (c *Client) IncrBy(key string, increment int64) (int64, error)
- func (c *Client) IncrByFloat(key string, increment float64) (string, error)
- func (c *Client) Info(section string) (ret string, err error)
- func (c *Client) Keys(pattern string) ([]string, error)
- func (c *Client) LIndex(key string, index int64) (string, error)
- func (c *Client) LInsert(key string, where string, pivot interface{}, value interface{}) (int64, error)
- func (c *Client) LLen(key string) (int64, error)
- func (c *Client) LPop(key string) (string, error)
- func (c *Client) LPush(key string, values ...interface{}) (int64, error)
- func (c *Client) LPushX(key string, value interface{}) (int64, error)
- func (c *Client) LRange(key string, start int64, stop int64) ([]string, error)
- func (c *Client) LRem(key string, count int64, value interface{}) (int64, error)
- func (c *Client) LSet(key string, index int64, value interface{}) (string, error)
- func (c *Client) LTrim(key string, start int64, stop int64) (string, error)
- func (c *Client) LastSave() (int64, error)
- func (c *Client) MGet(keys ...string) ([]string, error)
- func (c *Client) MSet(values ...interface{}) (string, error)
- func (c *Client) MSetNX(values ...interface{}) (bool, error)
- func (c *Client) Migrate(host string, port uint, key string, destination string, timeout int64) (string, error)
- func (c *Client) Move(key string, db string) (bool, error)
- func (c *Client) Multi() (string, error)
- func (c *Client) Object(subcommand string, arguments ...interface{}) (string, error)
- func (c *Client) PExpire(key string, milliseconds int64) (bool, error)
- func (c *Client) PExpireAt(key string, milliseconds int64) (bool, error)
- func (c *Client) PSetEx(key string, milliseconds int64, value interface{}) (ret string, err error)
- func (c *Client) PSubscribe(cn chan []string, channel ...string) error
- func (c *Client) PTTL(key string) (int64, error)
- func (c *Client) PUnsubscribe(pattern ...string) error
- func (c *Client) Persist(key string) (bool, error)
- func (c *Client) Ping() (ret string, err error)
- func (c *Client) PubSub(subcommand string, arguments ...interface{}) ([]string, error)
- func (c *Client) Publish(channel string, message interface{}) (int64, error)
- func (c *Client) Quit() (s string, err error)
- func (c *Client) RPop(key string) (string, error)
- func (c *Client) RPopLPush(source string, destination string) (string, error)
- func (c *Client) RPush(key string, values ...interface{}) (int64, error)
- func (c *Client) RPushX(key string, value interface{}) (int64, error)
- func (c *Client) RandomKey() (string, error)
- func (c *Client) Rename(key string, newkey string) (string, error)
- func (c *Client) RenameNX(key string, newkey string) (bool, error)
- func (c *Client) Restore(key string, ttl int64, serializedValue string) (string, error)
- func (c *Client) SAdd(key string, member ...interface{}) (int64, error)
- func (c *Client) SCard(key string) (int64, error)
- func (c *Client) SDiff(key ...string) ([]string, error)
- func (c *Client) SDiffStore(destination string, key ...string) (int64, error)
- func (c *Client) SInter(key ...string) ([]string, error)
- func (c *Client) SInterStore(destination string, key ...string) (int64, error)
- func (c *Client) SIsMember(key string, member interface{}) (bool, error)
- func (c *Client) SMembers(key string) ([]string, error)
- func (c *Client) SMove(source string, destination string, member interface{}) (bool, error)
- func (c *Client) SPop(key string) (string, error)
- func (c *Client) SRandMember(key string, count int64) ([]string, error)
- func (c *Client) SRem(key string, members ...interface{}) (int64, error)
- func (c *Client) SScan(key string, cursor int64, arguments ...interface{}) (ret []interface{}, err error)
- func (c *Client) SUnion(key ...string) ([]string, error)
- func (c *Client) SUnionStore(destination string, key ...string) (int64, error)
- func (c *Client) Save() (string, error)
- func (c *Client) Scan(cursor int64, arguments ...interface{}) (ret []interface{}, err error)
- func (c *Client) ScriptExists(script ...string) ([]string, error)
- func (c *Client) ScriptFlush() (string, error)
- func (c *Client) ScriptKill() (string, error)
- func (c *Client) ScriptLoad(script string) (string, error)
- func (c *Client) Select(index int64) (string, error)
- func (c *Client) Set(key string, value interface{}) (ret string, err error)
- func (c *Client) SetBit(key string, offset int64, value int64) (int64, error)
- func (c *Client) SetEx(key string, seconds int64, value interface{}) (ret string, err error)
- func (c *Client) SetNX(key string, value interface{}) (bool, error)
- func (c *Client) SetRange(key string, offset int64, value interface{}) (int64, error)
- func (c *Client) SlaveOf(key string, port uint) (string, error)
- func (c *Client) SlowLog(subcommand string, argument interface{}) ([]string, error)
- func (c *Client) Sort(key string, arguments ...string) ([]string, error)
- func (c *Client) Strlen(key string) (int64, error)
- func (c *Client) Subscribe(cn chan []string, channel ...string) error
- func (c *Client) Sync() (string, error)
- func (c *Client) TTL(key string) (int64, error)
- func (c *Client) Time() ([]uint64, error)
- func (c *Client) Type(key string) (string, error)
- func (c *Client) Unsubscribe(channel ...string) error
- func (c *Client) Unwatch() (string, error)
- func (c *Client) Watch(key ...string) (string, error)
- func (c *Client) ZAdd(key string, arguments ...interface{}) (int64, error)
- func (c *Client) ZCard(key string) (int64, error)
- func (c *Client) ZCount(key string, min interface{}, max interface{}) (int64, error)
- func (c *Client) ZIncrBy(key string, increment int64, member interface{}) (string, error)
- func (c *Client) ZInterStore(destination string, numkeys int64, arguments ...interface{}) (int64, error)
- func (c *Client) ZRange(key string, values ...interface{}) ([]string, error)
- func (c *Client) ZRangeByScore(key string, values ...interface{}) ([]string, error)
- func (c *Client) ZRank(key string, member interface{}) (int64, error)
- func (c *Client) ZRem(key string, arguments ...interface{}) (int64, error)
- func (c *Client) ZRemRangeByRank(key string, start interface{}, stop interface{}) (int64, error)
- func (c *Client) ZRemRangeByScore(key string, min interface{}, max interface{}) (int64, error)
- func (c *Client) ZRevRange(key string, start int64, stop int64, params ...interface{}) ([]string, error)
- func (c *Client) ZRevRangeByScore(key string, start interface{}, stop interface{}, params ...interface{}) ([]string, error)
- func (c *Client) ZRevRank(key string, member interface{}) (int64, error)
- func (c *Client) ZScan(key string, cursor int64, arguments ...interface{}) (ret []interface{}, err error)
- func (c *Client) ZScore(key string, member interface{}) (int64, error)
- func (c *Client) ZUnionStore(destination string, numkeys int64, key string, params ...interface{}) (int64, error)
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
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A redis client
func (*Client) Append ¶
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.
func (*Client) Auth ¶
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.
func (*Client) BLPop ¶
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.
func (*Client) BRPop ¶
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.
func (*Client) BRPopLPush ¶
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.
func (*Client) BgRewriteAOF ¶
Instruct Redis to start an Append Only File rewrite process. The rewrite will create a small optimized version of the current Append Only File.
func (*Client) BgSave ¶
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.
func (*Client) BitOp ¶
Perform a bitwise operation between multiple keys (containing string values) and store the result in the destination key.
func (*Client) ClientGetName ¶
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.
func (*Client) ClientKill ¶
The CLIENT KILL command closes a given client connection identified by ip:port.
func (*Client) ClientList ¶
The CLIENT LIST command returns information and statistics about the client connections server in a mostly human readable format.
func (*Client) ClientSetName ¶
The CLIENT SETNAME command assigns a name to the current connection.
func (*Client) Command ¶
Command builds a command specified by the `values` interface and stores the result into the variable pointed by `dest`.
func (*Client) ConfigGet ¶
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.
func (*Client) ConfigResetStat ¶
Resets the statistics reported by Redis using the INFO command.
func (*Client) ConfigSet ¶
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.
func (*Client) ConnectNonBlock ¶
ConnectNonBlock connects the client to the given host and port (deprecated).
func (*Client) ConnectUnix ¶
ConnectUnix attempts to create a connection with a UNIX socket.
func (*Client) ConnectUnixNonBlock ¶
ConnectUnixNonBlock attempts to create a non-blocking connection with an UNIX socket (deprecated).
func (*Client) ConnectUnixWithTimeout ¶
ConnectUnixWithTimeout attempts to create a connection with an UNIX socket, giving up after the specified time.
func (*Client) ConnectWithTimeout ¶
ConnectWithTimeout attempts to connect to a redis-server, giving up after the specified time.
func (*Client) DebugObject ¶
DEBUG OBJECT is a debugging command that should not be used by clients. Check the OBJECT command instead.
func (*Client) DebugSegfault ¶
DEBUG SEGFAULT performs an invalid memory access that crashes Redis. It is used to simulate bugs during the development.
func (*Client) Decr ¶
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.
func (*Client) DecrBy ¶
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.
func (*Client) Discard ¶
Flushes all previously queued commands in a transaction and restores the connection state to normal.
func (*Client) Dump ¶
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.
func (*Client) Eval ¶
EVAL and EVALSHA are used to evaluate scripts using the Lua interpreter built into Redis starting from version 2.6.0.
func (*Client) EvalSHA ¶
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.
func (*Client) Exec ¶
Executes all previously queued commands in a transaction and restores the connection state to normal.
func (*Client) Expire ¶
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.
func (*Client) ExpireAt ¶
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).
func (*Client) FlushAll ¶
Delete all the keys of all the existing databases, not just the currently selected one. This command never fails.
func (*Client) FlushDB ¶
Delete all the keys of the currently selected DB. This command never fails.
func (*Client) Get ¶
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.
func (*Client) GetRange ¶
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.
func (*Client) GetSet ¶
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.
func (*Client) HDel ¶
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.
func (*Client) HGetAll ¶
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.
func (*Client) HIncrBy ¶
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.
func (*Client) HIncrByFloat ¶
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.
func (*Client) HMGet ¶
Returns the values associated with the specified fields in the hash stored at key.
func (*Client) HMSet ¶
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.
func (*Client) HScan ¶
func (c *Client) HScan(key string, cursor int64, arguments ...interface{}) (ret []interface{}, err error)
HSCAN iterates fields of Hash types and their associated values.
func (*Client) HSet ¶
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.
func (*Client) HSetNX ¶
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.
func (*Client) Incr ¶
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.
func (*Client) IncrBy ¶
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.
func (*Client) IncrByFloat ¶
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.
func (*Client) Info ¶
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.
func (*Client) LIndex ¶
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.
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.
func (*Client) LLen ¶
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.
func (*Client) LPush ¶
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.
func (*Client) LPushX ¶
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.
func (*Client) LRange ¶
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.
func (*Client) LRem ¶
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:
func (*Client) LSet ¶
Sets the list element at index to value. For more information on the index argument, see LINDEX.
func (*Client) LTrim ¶
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.
func (*Client) MGet ¶
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 ¶
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.
func (*Client) MSetNX ¶
Sets the given keys to their respective values. MSETNX will not perform any operation at all even if just a single key already exists.
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.
func (*Client) Move ¶
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.
func (*Client) Multi ¶
Marks the start of a transaction block. Subsequent commands will be queued for atomic execution using EXEC.
func (*Client) Object ¶
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.
func (*Client) PExpire ¶
This command works exactly like EXPIRE but the time to live of the key is specified in milliseconds instead of seconds.
func (*Client) PExpireAt ¶
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.
func (*Client) PSetEx ¶
PSetEx works exactly like SetEx with the sole difference that the expire time is specified in milliseconds instead of seconds.
func (*Client) PSubscribe ¶
Subscribes the client to the given patterns.
func (*Client) PTTL ¶
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.
func (*Client) PUnsubscribe ¶
Unsubscribes the client from the given patterns, or from all of them if none is given.
func (*Client) Persist ¶
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).
func (*Client) Ping ¶
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 ¶
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.
func (*Client) Quit ¶
Ask the server to close the connection. The connection is closed as soon as all pending replies have been written to the client.
func (*Client) RPopLPush ¶
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.
func (*Client) RPush ¶
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.
func (*Client) RPushX ¶
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.
func (*Client) Rename ¶
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.
func (*Client) RenameNX ¶
Renames key to newkey if newkey does not yet exist. It returns an error under the same conditions as RENAME.
func (*Client) Restore ¶
Create a key associated with a value that is obtained by deserializing the provided serialized value (obtained via DUMP).
func (*Client) SAdd ¶
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.
func (*Client) SDiff ¶
Returns the members of the set resulting from the difference between the first set and all the successive sets.
func (*Client) SDiffStore ¶
This command is equal to SDIFF, but instead of returning the resulting set, it is stored in destination.
func (*Client) SInter ¶
Returns the members of the set resulting from the intersection of all the given sets.
func (*Client) SInterStore ¶
This command is equal to SINTER, but instead of returning the resulting set, it is stored in destination.
func (*Client) SMove ¶
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.
func (*Client) SRandMember ¶
When called with just the key argument, return a random element from the set value stored at key.
func (*Client) SRem ¶
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.
func (*Client) SScan ¶
func (c *Client) SScan(key string, cursor int64, arguments ...interface{}) (ret []interface{}, err error)
SSCAN iterates elements of Sets types.
func (*Client) SUnion ¶
Returns the members of the set resulting from the union of all the given sets.
func (*Client) SUnionStore ¶
This command is equal to SUNION, but instead of returning the resulting set, it is stored in destination.
func (*Client) Save ¶
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.
func (*Client) ScriptExists ¶
Returns information about the existence of the scripts in the script cache.
func (*Client) ScriptFlush ¶
Flush the Lua scripts cache.
func (*Client) ScriptKill ¶
Kills the currently executing Lua script, assuming no write operation was yet performed by the script.
func (*Client) ScriptLoad ¶
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.
func (*Client) Select ¶
Select the DB with having the specified zero-based numeric index. New connections always use DB 0.
func (*Client) Set ¶
Set key to hold the string value. If key already holds a value, it is overwritten, regardless of its type.
func (*Client) SetEx ¶
SetEx sets key to hold the string value and set key to timeout after a given number of seconds.
func (*Client) SetNX ¶
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".
func (*Client) SetRange ¶
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.
func (*Client) SlaveOf ¶
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.
func (*Client) SlowLog ¶
This command is used in order to read and reset the Redis slow queries log.
func (*Client) Sort ¶
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.
func (*Client) Strlen ¶
Returns the length of the string value stored at key. An error is returned when key holds a non-string value.
func (*Client) TTL ¶
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.
func (*Client) Time ¶
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.
func (*Client) Type ¶
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.
func (*Client) Unsubscribe ¶
Unsubscribes the client from the given channels, or from all of them if none is given.
func (*Client) Watch ¶
Marks the given keys to be watched for conditional execution of a transaction.
func (*Client) ZAdd ¶
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.
func (*Client) ZCard ¶
Returns the sorted set cardinality (number of elements) of the sorted set stored at key.
func (*Client) ZCount ¶
Returns the number of elements in the sorted set at key with a score between min and max.
func (*Client) ZIncrBy ¶
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.
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.
func (*Client) ZRange ¶
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.
func (*Client) ZRangeByScore ¶
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.
func (*Client) ZRank ¶
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.
func (*Client) ZRem ¶
Removes the specified members from the sorted set stored at key. Non existing members are ignored.
func (*Client) ZRemRangeByRank ¶
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.
func (*Client) ZRemRangeByScore ¶
Removes all elements in the sorted set stored at key with a score between min and max (inclusive).
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.
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.
func (*Client) ZRevRank ¶
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.
func (*Client) ZScan ¶
func (c *Client) ZScan(key string, cursor int64, arguments ...interface{}) (ret []interface{}, err error)
ZSCAN iterates elements of Sorted Set types and their associated scores.
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.