godis package - github.com/piaohao/godis - Go Packages

This section is empty.

View Source

var (
	
	ListOptionBefore = newListOption("BEFORE")
	
	ListOptionAfter = newListOption("AFTER")
)

View Source

var (
	
	GeoUnitMi = newGeoUnit("mi")
	
	GeoUnitM = newGeoUnit("m")
	
	GeoUnitKm = newGeoUnit("km")
	
	GeoUnitFt = newGeoUnit("ft")
)

View Source

var (
	
	AggregateSum = newAggregate("SUM")
	
	AggregateMin = newAggregate("MIN")
	
	AggregateMax = newAggregate("MAX")
)

View Source

var (
	
	BitOpAnd = newBitOP("AND")
	
	BitOpOr = newBitOP("OR")
	
	BitOpXor = newBitOP("XOR")
	
	BitOpNot = newBitOP("NOT")
)

View Source

var (
	
	ResetSoft = newReset("SOFT")
	
	ResetHard = newReset("HARD")
)

View Source

var (
	
	StrBuilder = newStrBuilder()
	
	Int64Builder = newInt64Builder()
	
	StrArrBuilder = newStringArrayBuilder()
)

ErrLockTimeOut when get lock exceed the timeout,then return error

BoolToByteArr convert bool to byte array

ByteArrToFloat64 convert byte array to float64

ByteArrToStrReply convert byte array reply to string reply

Float64ToByteArr convert float64 to byte array

Float64ToStr convert float64 to string

Int64ToBoolReply convert int64 reply to bool reply

Int64ToByteArr convert int64 to byte array

IntToByteArr convert int to byte array

ObjArrToMapArrayReply convert object array reply to map array reply

func ObjToEvalResult(reply interface{}, err error) (interface{}, error)

ObjToEvalResult resolve response data when use script command

StrArrToByteArrArr convert string array to byte array list

StrArrToMapReply convert string array reply to map reply

StrStrArrToByteArrArr convert string and string array to byte array

StrStrArrToStrArr convert string and string array to string array

StrToFloat64Reply convert string reply to float64 reply

ToBoolArrReply convert object reply to bool array reply

ToBoolReply convert object reply to bool reply

ToFloat64Reply convert object reply to float64 reply

ToInt64ArrReply convert object reply to int64 array reply

ToInt64Reply convert object reply to int64 reply

ToMapReply convert object reply to map reply

ToStrArrReply convert object reply to string array reply

ToStrReply convert object reply to string reply

type Aggregate struct {
	
}

Aggregate aggregate,sum|min|max

AskDataError ask data error

BitOP bit operation struct

type BitPosParams struct {
	
}

BitPosParams bitpos params

type Builder interface {
	
}

Builder convert pipeline|transaction response data

type BusyError struct {
	Message string
}

BusyError operation is busy error

type ClusterError struct {
	Message string
}

ClusterError cluster basic error

type ClusterLocker struct {
	
}

ClusterLocker cluster lock client

func NewClusterLocker(option *ClusterOption, lockOption *LockOption) *ClusterLocker

NewClusterLocker create new cluster locker

TryLock acquire a lock,when it returns a non nil locker,get lock success, otherwise, it returns an error,get lock failed

UnLock when your business end,then release the locker

type ClusterMaxAttemptsError struct {
	Message string
}

ClusterMaxAttemptsError cluster operation exceed max attempts errror

type ClusterOperationError struct {
	Message string
}

ClusterOperationError cluster operation error

ClusterOption when you create a new cluster instance ,then you need set some option

type ConnectError struct {
	Message string
}

ConnectError redis connection error,such as io timeout

type DataError struct {
	Message string
}

DataError data error

type DebugParams struct {
	
}

DebugParams debug params

func NewDebugParamsObject(key string) *DebugParams

NewDebugParamsObject create debug paramas with key

func NewDebugParamsReload() *DebugParams

NewDebugParamsReload create debug params with reload

func NewDebugParamsSegfault() *DebugParams

NewDebugParamsSegfault create debug prams with segfault

type GeoCoordinate struct {
	
}

GeoCoordinate geo coordinate struct

func ObjArrToGeoCoordinateReply(reply []interface{}, err error) ([]*GeoCoordinate, error)

ObjArrToGeoCoordinateReply convert object array reply to GeoCoordinate reply

func ToGeoCoordArrReply(reply interface{}, err error) ([]*GeoCoordinate, error)

ToGeoCoordArrReply convert object reply to geocoordinate array reply

type GeoRadiusParams struct {
	
}

GeoRadiusParams geo radius param

func NewGeoRadiusParam() *GeoRadiusParams

NewGeoRadiusParam create a new geo radius param instance

Contains test geo param contains the key

Count fill the geo result with count

func (p *GeoRadiusParams) SortAscending() *GeoRadiusParams

SortAscending sort th geo result in ascending order

func (p *GeoRadiusParams) SortDescending() *GeoRadiusParams

SortDescending sort the geo result in descending order

func (p *GeoRadiusParams) WithCoord() *GeoRadiusParams

WithCoord fill the geo result with coordinate

func (p *GeoRadiusParams) WithDist() *GeoRadiusParams

WithDist fill the geo result with distance

type GeoRadiusResponse struct {
	
}

GeoRadiusResponse geo radius response

func ObjArrToGeoRadiusResponseReply(reply []interface{}, err error) ([]GeoRadiusResponse, error)

ObjArrToGeoRadiusResponseReply convert object array reply to GeoRadiusResponse reply

func ToGeoRespArrReply(reply interface{}, err error) ([]GeoRadiusResponse, error)

ToGeoRespArrReply convert object reply to GeoRadiusResponse array reply

GeoUnit geo unit,m|mi|km|ft

type ListOption struct {
	
}

ListOption list option

Lock different keys with different lock

LockOption locker options

Locker the lock client

func NewLocker(option *Option, lockOption *LockOption) *Locker

NewLocker create new locker

TryLock acquire a lock,when it returns a non nil locker,get lock success, otherwise, it returns an error,get lock failed

func (l *Locker) UnLock(lock *Lock) error

UnLock when your business end,then release the locker

MovedDataError cluster move data error

type NoReachableClusterNodeError struct {
	Message string
}

NoReachableClusterNodeError have no reachable cluster node error

type NoScriptError struct {
	Message string
}

NoScriptError has no script error

Pipeline redis pipeline struct

BLPopTimeout see redis command

func (p Pipeline) BRPopLPush(source, destination string, timeout int) (*Response, error)

BRPopLPush see redis command

BRPopTimeout see redis command

func (p Pipeline) BgRewriteAof() (*Response, error)

BgRewriteAof see redis command

func (p Pipeline) BgSave() (*Response, error)

BgSave see redis command

func (p Pipeline) ClusterAddSlots(slots ...int) (*Response, error)

ClusterAddSlots see redis command

func (p Pipeline) ClusterDelSlots(slots ...int) (*Response, error)

ClusterDelSlots see redis command

func (p Pipeline) ClusterGetKeysInSlot(slot int, count int) (*Response, error)

ClusterGetKeysInSlot see redis command

func (p Pipeline) ClusterInfo() (*Response, error)

ClusterInfo see redis command

ClusterMeet see redis command

func (p Pipeline) ClusterNodes() (*Response, error)

ClusterNodes see redis command

func (p Pipeline) ClusterSetSlotImporting(slot int, nodeID string) (*Response, error)

ClusterSetSlotImporting see redis command

func (p Pipeline) ClusterSetSlotMigrating(slot int, nodeID string) (*Response, error)

ClusterSetSlotMigrating see redis command

ClusterSetSlotNode see redis command

ConfigGet see redis command

func (p Pipeline) ConfigResetStat() (*Response, error)

ConfigResetStat see redis command

func (p Pipeline) ConfigSet(parameter, value string) (*Response, error)

ConfigSet see redis command

func (p Pipeline) DbSize() (*Response, error)

DbSize see redis command

EvalSha see redis command

func (p Pipeline) FlushAll() (*Response, error)

FlushAll see redis command

func (p Pipeline) FlushDB() (*Response, error)

FlushDB see redis command

func (p Pipeline) Info() (*Response, error)

Info see redis command

func (p Pipeline) LastSave() (*Response, error)

LastSave see redis command

PfCount see redis command

PfMerge see redis command

func (p Pipeline) Ping() (*Response, error)

Ping see redis command

func (p Pipeline) Publish(channel, message string) (*Response, error)

Publish see redis command

func (p Pipeline) RPopLPush(srcKey, destKey string) (*Response, error)

RPopLPush see redis command

func (Pipeline) RandomKey added in v0.0.11

func (p Pipeline) RandomKey() (*Response, error)

RandomKey see redis command

func (p Pipeline) RenameNx(oldkey, newkey string) (*Response, error)

RenameNx see redis command

SDiffStore see redis command

SInterStore see redis command

func (p Pipeline) SMove(srcKey, destKey, member string) (*Response, error)

SMove see redis command

SUnionStore see redis command

func (p Pipeline) Save() (*Response, error)

Save see redis command

func (p Pipeline) Select(index int) (*Response, error)

Select see redis command

func (p Pipeline) Shutdown() (*Response, error)

Shutdown see redis command

SortMulti see redis command

func (p Pipeline) Time() (*Response, error)

Time see redis command

ZInterStore see redis command

ZInterStoreWithParams see redis command

ZUnionStore see redis command

ZUnionStoreWithParams see redis command

Pool redis pool

func NewPool(config *PoolConfig, option *Option) *Pool

NewPool create new pool

func (p *Pool) GetResource() (*Redis, error)

GetResource get redis instance from pool

PoolConfig redis pool config, see go-commons-pool ObjectPoolConfig

type RedirectError struct {
	Message string
}

RedirectError cluster operation redirect error

Redis redis client tool

func NewRedis(option *Option) *Redis

NewRedis constructor for creating new redis

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

Time complexity: O(1). The amortized time complexity is O(1) assuming the appended value is small and the already present value is of any size, since the dynamic string library used by Redis will double the free space available on every reallocation.

return Integer reply, specifically the total length of the string after the append operation.

Auth when server is set password,then you need to auth password.

BLPop BLPOP (and BRPOP) is a blocking list pop primitive. You can see this commands as blocking versions of LPOP and RPOP able to block if the specified keys don't exist or contain empty lists.

The following is a description of the exact semantic. We describe BLPOP but the two commands are identical, the only difference is that BLPOP pops the element from the left (head) of the list, and BRPOP pops from the right (tail).

<b>Non blocking behavior</b>

When BLPOP is called, if at least one of the specified keys contain a non empty list, an element is popped from the head of the list and returned to the caller together with the name of the key (BLPOP returns a two elements array, the first element is the key, the second the popped value).

Keys are scanned from left to right, so for instance if you issue BLPOP list1 list2 list3 0 against a dataset where list1 does not exist but list2 and list3 contain non empty lists, BLPOP guarantees to return an element from the list stored at list2 (since it is the first non empty list starting from the left).

<b>Blocking behavior</b>

If none of the specified keys exist or contain non empty lists, BLPOP blocks until some other client performs a LPUSH or an RPUSH operation against one of the lists.

Once new data is present on one of the lists, the client finally returns with the name of the key unblocking it and the popped value.

When blocking, if a non-zero timeout is specified, the client will unblock returning a nil special value if the specified amount of seconds passed without a push operation against at least one of the specified keys.

The timeout argument is interpreted as an integer value. A timeout of zero means instead to block forever.

<b>Multiple clients blocking for the same keys</b>

Multiple clients can block for the same key. They are put into a queue, so the first to be served will be the one that started to wait earlier, in a first-blpopping first-served fashion.

<b>blocking POP inside a MULTI/EXEC transaction</b>

BLPOP and BRPOP can be used with pipelining (sending multiple commands and reading the replies in batch), but it does not make sense to use BLPOP or BRPOP inside a MULTI/EXEC block (a Redis transaction).

The behavior of BLPOP inside MULTI/EXEC when the list is empty is to return a multi-bulk nil reply, exactly what happens when the timeout is reached. If you like science fiction, think at it like if inside MULTI/EXEC the time will flow at infinite speed :)

return BLPOP returns a two-elements array via a multi bulk reply in order to return both the

unblocking key and the popped value.

When a non-zero timeout is specified, and the BLPOP operation timed out, the return
value is a nil multi bulk reply. Most client values will return false or nil
accordingly to the programming language used.

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

By default all the bytes contained in the string are examined. It is possible to specify the counting operation only in an interval passing the additional arguments start and end.

Like for the GETRANGE command start and end can contain negative values in order to index bytes starting from the end of the string, where -1 is the last byte, -2 is the penultimate, and so forth.

Non-existent keys are treated as empty strings, so the command will return zero.

Return value Integer reply The number of bits set to 1.

BitCountRange see BitCount()

BitField The command treats a Redis string as a array of bits, and is capable of addressing specific integer fields of varying bit widths and arbitrary non (necessary) aligned offset.

BitPos Return the position of the first bit set to 1 or 0 in a string.

Close close redis connection

ClusterCountKeysInSlot ...

ClusterFailOver This command, that can only be sent to a Redis Cluster replica node, forces the replica to start a manual failover of its master instance.

ClusterNodes Each node in a Redis Cluster has its view of the current cluster configuration, given by the set of known nodes, the state of the connection we have with such nodes, their flags, properties and assigned slots, and so forth.

ClusterSetSlotImporting ...

ClusterSetSlotMigrating ...

func (r *Redis) ClusterSlots() ([]interface{}, error)

ClusterSlots ...

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.

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.

DbSize return key count of current db

Decr Decrement the number stored at key by one. If the key does not exist or contains a value of a wrong type, set the key to the value of "0" before to perform the decrement operation.

INCR commands are limited to 64 bit signed integers.

Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.

return Integer reply, this commands will reply with the new value of key after the increment.

DecrBy work just like {@link #decr(String) INCR} but instead to decrement by 1 the decrement is integer.

INCR commands are limited to 64 bit signed integers.

Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.

return Integer reply, this commands will reply with the new value of key after the increment.

Del Remove the specified keys. If a given key does not exist no operation is performed for this key. The command returns the number of keys removed. param keys return Integer reply, specifically: an integer greater than 0 if one or more keys were removed

0 if none of the specified key existed

Echo Returns message.

Return value Bulk string reply

Eval evaluate scripts using the Lua interpreter built into Redis

EvalByKeyArgs evaluate scripts using the Lua interpreter built into Redis

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.

Exists Test if the specified key exists. The command returns the number of keys existed param keys return Integer reply, specifically: an integer greater than 0 if one or more keys were removed

0 if none of the specified key existed

Expire Set a timeout on the specified key. After the timeout the key will be automatically deleted by the server. A key with an associated timeout is said to be volatile in Redis terminology.

Voltile keys are stored on disk like the other keys, the timeout is persistent too like all the other aspects of the dataset. Saving a dataset containing expires and stopping the server does not stop the flow of time as Redis stores on disk the time when the key will no longer be available as Unix time, and not the remaining seconds.

Since Redis 2.1.3 you can update the value of the timeout of a key already having an expire set. It is also possible to undo the expire at all turning the key into a normal key using the {@link #persist(String) PERSIST} command.

return Integer reply, specifically: 1: the timeout was set. 0: the timeout was not set since

the key already has an associated timeout (this may happen only in Redis versions &lt;
2.1.3, Redis &gt;= 2.1.3 will happily update the timeout), or the key does not exist.

ExpireAt EXPIREAT works exctly like {@link #expire(String, int) EXPIRE} but instead to get the number of seconds representing the Time To Live of the key as a second argument (that is a relative way of specifying the TTL), it takes an absolute one in the form of a UNIX timestamp (Number of seconds elapsed since 1 Gen 1970).

EXPIREAT was introduced in order to implement the Append Only File persistence mode so that EXPIRE commands are automatically translated into EXPIREAT commands for the append only file. Of course EXPIREAT can also used by programmers that need a way to simply specify that a given key should expire at a given time in the future.

Since Redis 2.1.3 you can update the value of the timeout of a key already having an expire set. It is also possible to undo the expire at all turning the key into a normal key using the {@link #persist(String) PERSIST} command.

return Integer reply, specifically: 1: the timeout was set. 0: the timeout was not set since

the key already has an associated timeout (this may happen only in Redis versions &lt;
2.1.3, Redis &gt;= 2.1.3 will happily update the timeout), or the key does not exist.

FlushAll it will clear whole keys in whole db

FlushDB it will clear whole keys in current db

GeoAddByMap add geo point by map Return value Integer reply, specifically: The number of elements added to the sorted set, not including elements already existing for which the score was updated.

GeoDist calculate distance of geo points

GeoHash get geo point hash

GeoRadius get members in certain range

GeoRadiusByMember get members in certain range

Get the value of the specified key. If the key does not exist null is returned. If the value stored at key is not a string an error is returned because GET can only handle string values. param key return Bulk reply

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

When offset is beyond the string length, the string is assumed to be a contiguous space with 0 bits. When key does not exist it is assumed to be an empty string, so offset is always out of range and the value is also assumed to be a contiguous space with 0 bits.

Return value Integer reply: the bit value stored at offset.

GetRange Warning: this command was renamed to GETRANGE, it is called SUBSTR in Redis versions <= 2.0. 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.

The function handles out of range requests by limiting the resulting range to the actual length of the string.

Return value Bulk string reply

GetSet GETSET is an atomic set this value and return the old value command. Set key to the string value and return the old value stored at key. The string can't be longer than 1073741824 bytes (1 GB).

return Bulk reply

HDel Remove the specified field from an hash stored at key.

return If the field was present in the hash it is deleted and 1 is returned, otherwise 0 is returned and no operation is performed.

HExists Test for existence of a specified field in a hash.

Return 1 if the hash stored at key contains the specified field. Return 0 if the key is not found or the field is not present.

HGet If key holds a hash, retrieve the value associated to the specified field.

If the field is not found or the key does not exist, a special 'nil' value is returned.

return Bulk reply

HGetAll Return all the fields and associated values in a hash.

return All the fields and values contained into a hash.

HIncrBy Increment the number stored at field in the hash at key by value. If key does not exist, a new key holding a hash is created. If field does not exist or holds a string, the value is set to 0 before applying the operation. Since the value argument is signed you can use this command to perform both increments and decrements.

The range of values supported by HINCRBY is limited to 64 bit signed integers.

return Integer reply The new value at field after the increment operation.

HIncrByFloat Increment the number stored at field in the hash at key by a double precision floating point value. If key does not exist, a new key holding a hash is created. If field does not exist or holds a string, the value is set to 0 before applying the operation. Since the value argument is signed you can use this command to perform both increments and decrements.

The range of values supported by HINCRBYFLOAT is limited to double precision floating point values.

return Double precision floating point reply The new value at field after the increment

operation.

HKeys Return all the fields in a hash.

return All the fields names contained into a hash.

HLen Return the number of items in a hash.

return The number of entries (fields) contained in the hash stored at key. If the specified key does not exist, 0 is returned assuming an empty hash.

HMGet Retrieve the values associated to the specified fields.

If some of the specified fields do not exist, nil values are returned. Non existing keys are considered like empty hashes.

return Multi Bulk Reply specifically a list of all the values associated with the specified

fields, in the same order of the request.

HMSet Set the respective fields to the respective values. HMSET replaces old values with new values.

If key does not exist, a new key holding a hash is created.

return Return OK or Exception if hash is empty

HScan scan keys of hash , see scan

HSet Set the specified hash field to the specified value.

If key does not exist, a new key holding a hash is created.

return If the field already exists, and the HSET just produced an update of the value, 0 is

returned, otherwise if a new field is created 1 is returned.

HSetNx Set the specified hash field to the specified value if the field not exists.

return If the field already exists, 0 is returned, otherwise if a new field is created 1 is returned.

HVals Return all the values in a hash.

return All the fields values contained into a hash.

Incr Increment the number stored at key by one. If the key does not exist or contains a value of a wrong type, set the key to the value of "0" before to perform the increment operation.

INCR commands are limited to 64 bit signed integers.

Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.

return Integer reply, this commands will reply with the new value of key after the increment.

IncrBy work just like {@link #incr(String) INCR} but instead to increment by 1 the increment is integer.

INCR commands are limited to 64 bit signed integers.

Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.

return Integer reply, this commands will reply with the new value of key after the increment.

IncrByFloat commands are limited to double precision floating point values.

Note: this is actually a string operation, that is, in Redis there are not "double" types. Simply the string stored at the key is parsed as a base double precision floating point value, incremented, and then converted back as a string. There is no DECRYBYFLOAT but providing a negative value will work as expected.

return Double reply, this commands will reply with the new value of key after the increment.

Keys Returns all the keys matching the glob-style pattern as space separated strings. For example if you have in the database the keys "foo" and "foobar" the command "KEYS foo*" will return "foo foobar".

Note that while the time complexity for this operation is O(n) the constant times are pretty low. For example Redis running on an entry level laptop can scan a 1 million keys database in 40 milliseconds. <b>Still it's better to consider this one of the slow commands that may ruin the DB performance if not used with care.</b>

In other words this command is intended only for debugging and special operations like creating a script to change the DB schema. Don't use it in your normal code. Use Redis Sets in order to group together a subset of objects.

Glob style patterns examples: <ul> <li>h?llo will match hello hallo hhllo <li>h*llo will match hllo heeeello <li>h[ae]llo will match hello and hallo, but not hillo </ul>

Use \ to escape special chars if you want to match them verbatim.

return Multi bulk reply

LIndex Return the specified element of the list stored at the specified key. 0 is the first element, 1 the second and so on. Negative indexes are supported, for example -1 is the last element, -2 the penultimate and so on.

If the value stored at key is not of list type an error is returned. If the index is out of range a 'nil' reply is returned.

return Bulk reply, specifically the requested element

LInsert Inserts value in the list stored at key either before or after the reference value pivot. When key does not exist, it is considered an empty list and no operation is performed. An error is returned when key exists but does not hold a list value.

Return value Integer reply: the length of the list after the insert operation, or -1 when the value pivot was not found.

LLen Return the length of the list stored at the specified key. If the key does not exist zero is returned (the same behaviour as for empty lists). If the value stored at key is not a list an error is returned.

return The length of the list.

LPop Atomically return and remove the first (LPOP) or last (RPOP) element of the list. For example if the list contains the elements "a","b","c" LPOP will return "a" and the list will become "b","c".

If the key does not exist or the list is already empty the special value 'nil' is returned.

return Bulk reply

LPush Add the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key. If the key does not exist an empty list is created just before the append operation. If the key exists but is not a List an error is returned.

return Integer reply, specifically, the number of elements inside the list after the push

operation.

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. Return value Integer reply: the length of the list after the push operation.

LRange Return the specified elements of the list stored at the specified key. Start and end are zero-based indexes. 0 is the first element of the list (the list head), 1 the next element and so on.

For example LRANGE foobar 0 2 will return the first three elements of the list.

start and end can also be negative numbers indicating offsets from the end of the list. For example -1 is the last element of the list, -2 the penultimate element and so on.

<b>Consistency with range functions in various programming languages</b>

Note that if you have a list of numbers from 0 to 100, LRANGE 0 10 will return 11 elements, that is, rightmost item is included. This may or may not be consistent with behavior of range-related functions in your programming language of choice (think Ruby's Range.new, Array#slice or Python's range() function).

LRANGE behavior is consistent with one of Tcl.

Indexes out of range will not produce an error: if start is over the end of the list, or start &gt; end, an empty list is returned. If end is over the end of the list Redis will threat it just like the last element of the list.

return Multi bulk reply, specifically a list of elements in the specified range.

LRem Remove the first count occurrences of the value element from the list. If count is zero all the elements are removed. If count is negative elements are removed from tail to head, instead to go from head to tail that is the normal behaviour. So for example LREM with count -2 and hello as value to remove against the list (a,b,c,hello,x,hello,hello) will lave the list (a,b,c,hello,x). The number of removed elements is returned as an integer, see below for more information about the returned value. Note that non existing keys are considered like empty lists by LREM, so LREM against non existing keys will always return 0.

return Integer Reply, specifically: The number of removed elements if the operation succeeded

LSet Set a new value as the element at index position of the List at key.

Out of range indexes will generate an error.

Similarly to other list commands accepting indexes, the index can be negative to access elements starting from the end of the list. So -1 is the last element, -2 is the penultimate, and so forth.

return Status code reply

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

For example LTRIM foobar 0 2 will modify the list stored at foobar key so that only the first three elements of the list will remain.

start and end can also be negative numbers indicating offsets from the end of the list. For example -1 is the last element of the list, -2 the penultimate element and so on.

Indexes out of range will not produce an error: if start is over the end of the list, or start &gt; end, an empty list is left as value. If end over the end of the list Redis will threat it just like the last element of the list.

Hint: the obvious use of LTRIM is together with LPUSH/RPUSH. For example:

{@code lpush("mylist", "someelement"); ltrim("mylist", 0, 99); //}

The above two commands will push elements in the list taking care that the list will not grow without limits. This is very useful when using Redis to store logs for example. It is important to note that when used in this way LTRIM is an O(1) operation because in the average case just one element is removed from the tail of the list.

return Status code reply

MGet Get the values of all the specified keys. If one or more keys dont exist or is not of type String, a 'nil' value is returned instead of the value of the specified key, but the operation never fails.

return Multi bulk reply

MSet Set the the respective keys to the respective values. MSET will replace old values with new values, while {@link #msetnx(String...) MSETNX} will not perform any operation at all even if just a single key already exists.

Because of this semantic MSETNX can be used in order to set different keys representing different fields of an unique logic object in a way that ensures that either all the fields or none at all are set.

Both MSET and MSETNX are atomic operations. This means that for instance if the keys A and B are modified, another client talking to Redis can either see the changes to both A and B at once, or no modification at all. return Status code reply Basically +OK as MSET can't fail

MSetNx Set the the respective keys to the respective values. {@link #mset(String...) MSET} will replace old values with new values, while MSETNX will not perform any operation at all even if just a single key already exists.

Because of this semantic MSETNX can be used in order to set different keys representing different fields of an unique logic object in a way that ensures that either all the fields or none at all are set.

Both MSET and MSETNX are atomic operations. This means that for instance if the keys A and B are modified, another client talking to Redis can either see the changes to both A and B at once, or no modification at all. return Integer reply, specifically: 1 if the all the keys were set 0 if no key was set (at

least one key already existed)

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.

Return value Integer reply, specifically:

1 if key was moved. 0 if key was not moved.

Multi get transaction of redis client ,when use transaction mode, you need to invoke this first

ObjectEncoding returns the kind of internal representation used in order to store the value associated with a key.

ObjectIdleTime returns the number of seconds since the object stored at the specified key is idle (not requested by read or write operations). While the value is returned in seconds the actual resolution of this timer is 10 seconds, but may vary in future implementations. This subcommand is available when maxmemory-policy is set to an LRU policy or noeviction.

ObjectRefCount returns the number of references of the value associated with the specified key. This command is mainly useful for debugging.

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

Return value Integer reply, specifically:

1 if the timeout was set. 0 if key does not exist.

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.

Return value Integer reply, specifically:

1 if the timeout was set. 0 if key does not exist.

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

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. In Redis 2.6 or older the command returns -1 if the key does not exist or if the key exist but has no associated expire. Starting with Redis 2.8 the return value in case of error changed: The command returns -2 if the key does not exist. The command returns -1 if the key exists but has no associated expire.

Integer reply: TTL in milliseconds, or a negative value in order to signal an error (see the description above).

Persist Undo a {@link #expire(String, int) expire} at turning the expire key into a normal key.

return Integer reply, specifically: 1: the key is now persist. 0: the key is not persist (only

happens when key not set).

PfAdd Adds all the element arguments to the HyperLogLog data structure stored at the variable name specified as first argument. Return value Integer reply, specifically:

1 if at least 1 HyperLogLog internal register was altered. 0 otherwise.

PfCount When called with a single key, returns the approximated cardinality computed by the HyperLogLog data structure stored at the specified variable, which is 0 if the variable does not exist. Return value Integer reply, specifically:

The approximated number of unique elements observed via PFADD.

PfMerge Merge multiple HyperLogLog values into an unique value that will approximate the cardinality of the union of the observed Sets of the source HyperLogLog structures.

The computed merged HyperLogLog is set to the destination variable, which is created if does not exist (defaulting to an empty HyperLogLog).

Return value Simple string reply: The command just returns OK.

Ping send ping command to redis server if the sever is running well,then it will return PONG.

func (r *Redis) Pipelined() *Pipeline

Pipelined get pipeline of redis client ,when use pipeline mode, you need to invoke this first

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

Return value Simple string reply: always OK.

RPop Atomically return and remove the first (LPOP) or last (RPOP) element of the list. For example if the list contains the elements "a","b","c" RPOP will return "c" and the list will become "a","b".

If the key does not exist or the list is already empty the special value 'nil' is returned.

return Bulk reply

RPopLPush Atomically return and remove the last (tail) element of the srcKey list, and push the element as the first (head) element of the destKey list. For example if the source list contains the elements "a","b","c" and the destination list contains the elements "foo","bar" after an RPOPLPUSH command the content of the two lists will be "a","b" and "c","foo","bar".

If the key does not exist or the list is already empty the special value 'nil' is returned. If the srcKey and destKey are the same the operation is equivalent to removing the last element from the list and pusing it as first element of the list, so it's a "list rotation" command.

return Bulk reply

RPush Add the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key. If the key does not exist an empty list is created just before the append operation. If the key exists but is not a List an error is returned.

return Integer reply, specifically, the number of elements inside the list after the push

operation.

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.

Return value Integer reply: the length of the list after the push operation.

Readonly Enables read queries for a connection to a Redis Cluster replica node. Normally replica nodes will redirect clients to the authoritative master for the hash slot involved in a given command, however clients can use replicas in order to scale reads using the READONLY command.

READONLY tells a Redis Cluster replica node that the client is willing to read possibly stale data and is not interested in running write queries.

When the connection is in readonly mode, the cluster will send a redirection to the client only if the operation involves keys not served by the replica's master node. This may happen because:

The client sent a command about hash slots never served by the master of this replica. The cluster was reconfigured (for example resharded) and the replica is no longer able to serve commands for a given hash slot. Return value Simple string reply

func (r *Redis) Receive() (interface{}, error)

Receive receive reply from redis

Rename Atomically renames the key oldKey to newKey. If the source and destination name are the same an error is returned. If newKey already exists it is overwritten.

return Status code repy

RenameNx Rename oldKey into newKey but fails if the destination key newKey already exists.

return Integer reply, specifically: 1 if the key was renamed 0 if the target key already exist

SAdd Add the specified member to the set value stored at key. If member is already a member of the set no operation is performed. If key does not exist a new set with the specified member as sole member is created. If the key exists but does not hold a set value an error is returned.

return Integer reply, specifically: 1 if the new element was added 0 if the element was

already a member of the set

SCard Return the set cardinality (number of elements). If the key does not exist 0 is returned, like for empty sets. return Integer reply, specifically: the cardinality (number of elements) of the set as an

integer.

SDiff Return the difference between the Set stored at key1 and all the Sets key2, ..., keyN

<b>Example:</b> <pre> key1 = [x, a, b, c] key2 = [c] key3 = [a, d] SDIFF key1,key2,key3 =&gt; [x, b] </pre> Non existing keys are considered like empty sets.

return Return the members of a set resulting from the difference between the first set

provided and all the successive sets.

SDiffStore This command works exactly like {@link #sdiff(String...) SDIFF} but instead of being returned the resulting set is stored in destKey. return Status code reply

SInter Return the members of a set resulting from the intersection of all the sets hold at the specified keys. Like in {@link #lrange(String, long, long) LRANGE} the result is sent to the client as a multi-bulk reply (see the protocol specification for more information). If just a single key is specified, then this command produces the same result as {@link #smembers(String) SMEMBERS}. Actually SMEMBERS is just syntax sugar for SINTER.

Non existing keys are considered like empty sets, so if one of the keys is missing an empty set is returned (since the intersection with an empty set always is an empty set).

return Multi bulk reply, specifically the list of common elements.

SInterStore This commnad works exactly like {@link #sinter(String...) SINTER} but instead of being returned the resulting set is sotred as destKey.

return Status code reply

SIsMember Return 1 if member is a member of the set stored at key, otherwise 0 is returned.

return Integer reply, specifically: 1 if the element is a member of the set 0 if the element

is not a member of the set OR if the key does not exist

SMembers Return all the members (elements) of the set value stored at key.

return Multi bulk reply

SMove Move the specifided member from the set at srcKey to the set at destKey. This operation is atomic, in every given moment the element will appear to be in the source or destination set for accessing clients.

If the source set does not exist or does not contain the specified element no operation is performed and zero is returned, otherwise the element is removed from the source set and added to the destination set. On success one is returned, even if the element was already present in the destination set.

An error is raised if the source or destination keys contain a non Set value.

return Integer reply, specifically: 1 if the element was moved 0 if the element was not found

on the first set and no operation was performed

SPop Remove a random element from a Set returning it as return value. If the Set is empty or the key does not exist, a nil object is returned.

The {@link #srandmember(String)} command does a similar work but the returned element is not removed from the Set.

return Bulk reply

SPopBatch remove multi random element see SPop(key string)

func (*Redis) SRandMember added in v0.0.11

SRandMember Return a random element from a Set, without removing the element. If the Set is empty or the key does not exist, a nil object is returned.

The SPOP command does a similar work but the returned element is popped (removed) from the Set.

return Bulk reply

func (*Redis) SRandMemberBatch added in v0.0.11

SRandMemberBatch see SRandMember(key string)

SRem Remove the specified member from the set value stored at key. If member was not a member of the set no operation is performed. If key does not hold a set value an error is returned.

return Integer reply, specifically: 1 if the new element was removed 0 if the new element was

not a member of the set

SScan scan keys of set,see scan

SUnion Return the members of a set resulting from the union of all the sets hold at the specified keys. Like in {@link #lrange(String, long, long) LRANGE} the result is sent to the client as a multi-bulk reply (see the protocol specification for more information). If just a single key is specified, then this command produces the same result as {@link #smembers(String) SMEMBERS}.

Non existing keys are considered like empty sets.

return Multi bulk reply, specifically the list of common elements.

SUnionStore This command works exactly like {@link #sunion(String...) SUNION} but instead of being returned the resulting set is stored as destKey. Any existing value in destKey will be over-written.

return Status code reply

ScriptExists Returns information about the existence of the scripts in the script cache. Return value Array reply The command returns an array of integers that correspond to the specified SHA1 digest arguments. For every corresponding SHA1 digest of a script that actually exists in the script cache, an 1 is returned, otherwise 0 is returned.

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. Return value Bulk string reply This command returns the SHA1 digest of the script added into the script cache.

Select send select command to change current db,normally redis server has 16 db [0,15]

func (r *Redis) Send(command protocolCommand, args ...[]byte) error

Send send command to redis

SendByStr send command to redis

SentinelGetMasterAddrByName example: redis 127.0.0.1:26381&gt; sentinel get-master-addr-by-name mymaster 1) "127.0.0.1" 2) "6379" return two elements list of strings : host and port.

SentinelMasters example: redis 127.0.0.1:26381&gt; sentinel masters 1) 1) "name"

  1. "mymaster"
  2. "ip"
  3. "127.0.0.1"
  4. "port"
  5. "6379"
  6. "runid"
  7. "93d4d4e6e9c06d0eea36e27f31924ac26576081d"
  8. "flags"
  9. "master"
  10. "pending-commands"
  11. "0"
  12. "last-ok-ping-reply"
  13. "423"
  14. "last-ping-reply"
  15. "423"
  16. "info-refresh"
  17. "6107"
  18. "num-slaves"
  19. "1"
  20. "num-other-sentinels"
  21. "2"
  22. "quorum"
  23. "2"

SentinelReset example: redis 127.0.0.1:26381&gt; sentinel reset mymaster (integer) 1

SentinelSlaves example: redis 127.0.0.1:26381&gt; sentinel slaves mymaster 1) 1) "name"

  1. "127.0.0.1:6380"
  2. "ip"
  3. "127.0.0.1"
  4. "port"
  5. "6380"
  6. "runid"
  7. "d7f6c0ca7572df9d2f33713df0dbf8c72da7c039"
  8. "flags"
  9. "slave"
  10. "pending-commands"
  11. "0"
  12. "last-ok-ping-reply"
  13. "47"
  14. "last-ping-reply"
  15. "47"
  16. "info-refresh"
  17. "657"
  18. "master-link-down-time"
  19. "0"
  20. "master-link-status"
  21. "ok"
  22. "master-host"
  23. "localhost"
  24. "master-port"
  25. "6379"
  26. "slave-priority"
  27. "100"

Set the string value as value of the key. The string can't be longer than 1073741824 bytes (1 GB) return Status code reply

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

The bit is either set or cleared depending on value, which can be either 0 or 1. When key does not exist, a new string value is created. The string is grown to make sure it can hold a bit at offset. The offset argument is required to be greater than or equal to 0, and smaller than 232 (this limits bitmaps to 512MB). When the string at key is grown, added bits are set to 0.

Warning: When setting the last possible bit (offset equal to 232 -1) and the string value stored at key does not yet hold a string value, or holds a small string value, Redis needs to allocate all intermediate memory which can block the server for some time. On a 2010 MacBook Pro, setting bit number 232 -1 (512MB allocation) takes ~300ms, setting bit number 230 -1 (128MB allocation) takes ~80ms, setting bit number 228 -1 (32MB allocation) takes ~30ms and setting bit number 226 -1 (8MB allocation) takes ~8ms. Note that once this first allocation is done, subsequent calls to SETBIT for the same key will not have the allocation overhead.

Return value Integer reply: the original bit value stored at offset.

SetBitWithBool see SetBit(key string, offset int64, value string)

SetEx The command is exactly equivalent to the following group of commands: {@link #set(String, String) SET} + {@link #expire(String, int) EXPIRE}. The operation is atomic.

return Status code reply

SetNx SETNX works exactly like {@link #set(String, String) SET} with the only difference that if the key already exists no operation is performed. SETNX actually means "SET if Not eXists".

return Integer reply, specifically: 1 if the key was set 0 if the key was not set

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. Note that the maximum offset that you can set is 229 -1 (536870911), as Redis Strings are limited to 512 megabytes. If you need to grow beyond this size, you can use multiple keys.

Warning: When setting the last possible byte and the string value stored at key does not yet hold a string value, or holds a small string value, Redis needs to allocate all intermediate memory which can block the server for some time. On a 2010 MacBook Pro, setting byte number 536870911 (512MB allocation) takes ~300ms, setting byte number 134217728 (128MB allocation) takes ~80ms, setting bit number 33554432 (32MB allocation) takes ~30ms and setting bit number 8388608 (8MB allocation) takes ~8ms. Note that once this first allocation is done, subsequent calls to SETRANGE for the same key will not have the allocation overhead.

Return value Integer reply: the length of the string after it was modified by the command.

SetWithParams see SetWithParamsAndTime(key, value, nxxx, expx string, time int64)

func (*Redis) SetWithParamsAndTime

SetWithParamsAndTime Set the string value as value of the key. The string can't be longer than 1073741824 bytes (1 GB). param nxxx NX|XX, NX -- Only set the key if it does not already exist. XX -- Only set the key if it already exist. param expx EX|PX, expire time units: EX = seconds; PX = milliseconds param time expire time in the units of <code>expx</code> return Status code reply

SlowLogGet The Redis Slow Log is a system to log queries that exceeded a specified execution time. The execution time does not include I/O operations like talking with the client, sending the reply and so forth, but just the time needed to actually execute the command (this is the only stage of command execution where the thread is blocked and can not serve other requests in the meantime).

SlowLogLen it is possible to get just the length of the slow log using the command SLOWLOG LEN.

SlowLogReset You can reset the slow log using the SLOWLOG RESET command. Once deleted the information is lost forever.

Sort a Set or a List.

Sort the elements contained in the List, Set, or Sorted Set value at key. By default sorting is numeric with elements being compared as double precision floating point numbers. This is the simplest form of SORT. return Assuming the Set/List at key contains a list of numbers, the return value will be the

list of numbers ordered from the smallest to the biggest number.

SortStore sort old sets or list,then store the result to a new set or list

StrLen Returns the length of the string value stored at key. An error is returned when key holds a non-string value. Return value Integer reply: the length of the string at key, or 0 when key does not exist.

SubStr Return a subset of the string from offset start to offset end (both offsets 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 char, -2 the penultimate and so forth.

The function handles out of range requests without raising an error, but just limiting the resulting range to the actual length of the string.

Time complexity: O(start+n) (with start being the start index and n the total length of the requested range). Note that the lookup part of this command is O(1) so for small strings this is actually an O(1) command.

return Bulk reply

TTL The TTL command returns the remaining time to live in seconds of a key that has an {@link #expire(String, int) EXPIRE} set. This introspection capability allows a Redis client to check how many seconds a given key will continue to be part of the dataset. return Integer reply, returns the remaining time to live in seconds of a key that has an

EXPIRE. In Redis 2.6 or older, if the Key does not exists or does not have an
associated expire, -1 is returned. In Redis 2.8 or newer, if the Key does not have an
associated expire, -1 is returned or if the Key does not exists, -2 is returned.

Type Return the type of the value stored at key in form of a string. The type can be one of "none", "string", "list", "set". "none" is returned if the key does not exist. Time complexity: O(1) param key return Status code reply, specifically: "none" if the key does not exist "string" if the key

contains a String value "list" if the key contains a List value "set" if the key
contains a Set value "zset" if the key contains a Sorted Set value "hash" if the key
contains a Hash value

Unwatch cancel all watches for keys always return OK

WaitReplicas Synchronous replication of Redis as described here: http://antirez.com/news/66 Since Java Object class has implemented "wait" method, we cannot use it, so I had to change the name of the method. Sorry :S

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

Return value Simple string reply: always OK.

ZAdd Add the specified member having the specifeid score to the sorted set stored at key. If member is already a member of the sorted set the score is updated, and the element reinserted in the right position to ensure sorting. If key does not exist a new sorted set with the specified member as sole member is crated. If the key exists but does not hold a sorted set value an error is returned.

The score value can be the string representation of a double precision floating point number.

return Integer reply, specifically: 1 if the new element was added 0 if the element was

already a member of the sorted set and the score was updated

ZAddByMap see ZAdd(key string, score float64, member string, mparams ...ZAddParams)

ZCard Return the sorted set cardinality (number of elements). If the key does not exist 0 is returned, like for empty sorted sets.

return the cardinality (number of elements) of the set as an integer.

ZCount Returns the number of elements in the sorted set at key with a score between min and max. The min and max arguments have the same semantic as described for ZRANGEBYSCORE. Note: the command has a complexity of just O(log(N)) because it uses elements ranks (see ZRANK) to get an idea of the range. Because of this there is no need to do a work proportional to the size of the range.

Return value Integer reply: the number of elements in the specified score range.

ZIncrBy If member already exists in the sorted set adds the increment to its score and updates the position of the element in the sorted set accordingly. If member does not already exist in the sorted set it is added with increment as score (that is, like if the previous score was virtually zero). If key does not exist a new sorted set with the specified member as sole member is crated. If the key exists but does not hold a sorted set value an error is returned.

The score value can be the string representation of a double precision floating point number. It's possible to provide a negative value to perform a decrement.

For an introduction to sorted sets check the Introduction to Redis data types page.

return The new score

ZInterStore Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at destKey. It is mandatory to provide the number of input keys N, before passing the input keys and the other (optional) arguments.

As the terms imply, the {@link #zinterstore(String, String...) ZINTERSTORE} command requires an element to be present in each of the given inputs to be inserted in the result. The {@link #zunionstore(String, String...) ZUNIONSTORE} command inserts all elements across all inputs.

Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.

With the AGGREGATE option, it's possible to specify how the results of the union or intersection are aggregated. This option defaults to SUM, where the score of an element is summed across the inputs where it exists. When this option is set to be either MIN or MAX, the resulting set will contain the minimum or maximum score of an element across the inputs where it exists.

return Integer reply, specifically the number of elements in the sorted set at destKey

ZInterStoreWithParams ...

ZLexCount When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns the number of elements in the sorted set at key with a value between min and max.

The min and max arguments have the same meaning as described for ZRANGEBYLEX.

Return value Integer reply: the number of elements in the specified score range.

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. See ZREVRANGE when you need the elements ordered from highest to lowest score (and descending lexicographical order for elements with equal score). Both start and stop are zero-based indexes, where 0 is the first element, 1 is the next element and so on. They can also be negative numbers indicating offsets from the end of the sorted set, with -1 being the last element of the sorted set, -2 the penultimate element and so on. start and stop are inclusive ranges, so for example ZRANGE myzset 0 1 will return both the first and the second element of the sorted set. Out of range indexes will not produce an error. If start is larger than the largest index in the sorted set, or start > stop, an empty list is returned. If stop is larger than the end of the sorted set Redis will treat it like it is the last element of the sorted set. It is possible to pass the WITHSCORES option in order to return the scores of the elements together with the elements. The returned list will contain value1,score1,...,valueN,scoreN instead of value1,...,valueN. Client libraries are free to return a more appropriate data type (suggestion: an array with (value, score) arrays/tuples). Return value Array reply: list of elements in the specified range (optionally with their scores, in case the WITHSCORES option is given).

ZRangeByLex When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at key with a value between min and max.

If the elements in the sorted set have different scores, the returned elements are unspecified.

The elements are considered to be ordered from lower to higher strings as compared byte-by-byte using the memcmp() C function. Longer strings are considered greater than shorter strings if the common part is identical.

The optional LIMIT argument can be used to only get a range of the matching elements (similar to SELECT LIMIT offset, count in SQL). A negative count returns all elements from the offset. Keep in mind that if offset is large, the sorted set needs to be traversed for offset elements before getting to the elements to return, which can add up to O(N) time complexity. Return value Array reply: list of elements in the specified score range.

ZRangeByLexBatch see ZRangeByLex()

ZRangeByScore Return the 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 having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).

Using the optional {@link #zrangeByScore(String, double, double, int, int) LIMIT} it's possible to get only a range of the matching elements in an SQL-alike way. Note that if offset is large the commands needs to traverse the list for offset elements and this adds up to the O(M) figure.

The {@link #zcount(String, double, double) ZCOUNT} command is similar to {@link #zrangeByScore(String, double, double) ZRANGEBYSCORE} but instead of returning the actual elements in the specified interval, it just returns the number of matching elements.

<b>Exclusive intervals and infinity</b>

min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".

Also while the interval is for default closed (inclusive) it's possible to specify open intervals prefixing the score with a "(" character, so for instance:

{@code ZRANGEBYSCORE zset (1.3 5}

Will return all the values with score &gt; 1.3 and &lt;= 5, while for instance:

{@code ZRANGEBYSCORE zset (5 (10}

Will return all the values with score &gt; 5 and &lt; 10 (5 and 10 excluded).

param min a double or Double.MIN_VALUE for "-inf" param max a double or Double.MAX_VALUE for "+inf" return Multi bulk reply specifically a list of elements in the specified score range.

ZRangeByScoreBatch see ZRange()

ZRangeByScoreWithScores Return the 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 having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).

Using the optional {@link #zrangeByScore(String, double, double, int, int) LIMIT} it's possible to get only a range of the matching elements in an SQL-alike way. Note that if offset is large the commands needs to traverse the list for offset elements and this adds up to the O(M) figure.

The {@link #zcount(String, double, double) ZCOUNT} command is similar to {@link #zrangeByScore(String, double, double) ZRANGEBYSCORE} but instead of returning the actual elements in the specified interval, it just returns the number of matching elements.

<b>Exclusive intervals and infinity</b>

min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".

Also while the interval is for default closed (inclusive) it's possible to specify open intervals prefixing the score with a "(" character, so for instance:

{@code ZRANGEBYSCORE zset (1.3 5}

Will return all the values with score &gt; 1.3 and &lt;= 5, while for instance:

{@code ZRANGEBYSCORE zset (5 (10}

Will return all the values with score &gt; 5 and &lt; 10 (5 and 10 excluded).

return Multi bulk reply specifically a list of elements in the specified score range.

ZRangeByScoreWithScoresBatch see ZRange()

ZRangeWithScores see ZRange()

ZRank Return the rank (or index) or member in the sorted set at key, with scores being ordered from low to high.

When the given member does not exist in the sorted set, the special value 'nil' is returned. The returned rank (or index) of the member is 0-based for both commands.

return Integer reply or a nil bulk reply, specifically: the rank of the element as an integer

reply if the element exists. A nil bulk reply if there is no such element.

ZRem Remove the specified member from the sorted set value stored at key. If member was not a member of the set no operation is performed. If key does not not hold a set value an error is returned.

return Integer reply, specifically: 1 if the new element was removed 0 if the new element was

not a member of the set

ZRemRangeByLex When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command removes all elements in the sorted set stored at key between the lexicographical range specified by min and max.

The meaning of min and max are the same of the ZRANGEBYLEX command. Similarly, this command actually returns the same elements that ZRANGEBYLEX would return if called with the same min and max arguments.

Return value Integer reply: the number of elements removed.

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

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

Since version 2.1.6, min and max can be exclusive, following the syntax of ZRANGEBYSCORE.

Return value Integer reply: the number of elements removed.

ZRevRange 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. Apart from the reversed ordering, ZREVRANGE is similar to ZRANGE. Return value Array reply: list of elements in the specified range (optionally with their scores).

ZRevRangeByLex When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at key with a value between max and min.

Apart from the reversed ordering, ZREVRANGEBYLEX is similar to ZRANGEBYLEX.

Return value Array reply: list of elements in the specified score range.

ZRevRangeByLexBatch see ZRevRangeByLex()

ZRevRangeByScore 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. The elements having the same score are returned in reverse lexicographical order. Apart from the reversed ordering, ZREVRANGEBYSCORE is similar to ZRANGEBYSCORE.

Return value Array reply: list of elements in the specified score range (optionally with their scores).

ZRevRangeByScoreWithScores see ZRevRangeByScore(key, max, min string)

ZRevRangeByScoreWithScoresBatch see ZRevRange()

ZRevRangeWithScores see ZRevRange()

ZRevRank Return the rank (or index) or member in the sorted set at key, with scores being ordered from high to low.

When the given member does not exist in the sorted set, the special value 'nil' is returned. The returned rank (or index) of the member is 0-based for both commands.

return Integer reply or a nil bulk reply, specifically: the rank of the element as an integer

reply if the element exists. A nil bulk reply if there is no such element.

ZScan scan keys of zset,see scan

ZScore Return the score of the specified element of the sorted set at key. If the specified element does not exist in the sorted set, or the key does not exist at all, a special 'nil' value is returned.

return the score

ZUnionStore Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at destKey. It is mandatory to provide the number of input keys N, before passing the input keys and the other (optional) arguments.

As the terms imply, the {@link #zinterstore(String, String...) ZINTERSTORE} command requires an element to be present in each of the given inputs to be inserted in the result. The {@link #zunionstore(String, String...) ZUNIONSTORE} command inserts all elements across all inputs.

Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.

With the AGGREGATE option, it's possible to specify how the results of the union or intersection are aggregated. This option defaults to SUM, where the score of an element is summed across the inputs where it exists. When this option is set to be either MIN or MAX, the resulting set will contain the minimum or maximum score of an element across the inputs where it exists.

return Integer reply, specifically the number of elements in the sorted set at destKey

ZUnionStoreWithParams ...

type RedisCluster struct {
	MaxAttempts int
	
}

RedisCluster redis cluster tool

func NewRedisCluster(option *ClusterOption) *RedisCluster

NewRedisCluster constructor

BLPop see comment in redis.go

BLPopTimeout see comment in redis.go

BRPop see comment in redis.go

BRPopLPush see redis command

BRPopTimeout see comment in redis.go

BitCount see comment in redis.go

BitCountRange see comment in redis.go

BitField see comment in redis.go

BitPos see comment in redis.go

Del delete one or more keys return the number of deleted keys

Echo see comment in redis.go

EvalSha see redis command

Exists see comment in redis.go

ExpireAt see redis command

GeoAdd see comment in redis.go

GeoAddByMap see comment in redis.go

GeoDist see comment in redis.go

GeoHash see comment in redis.go

GeoPos see comment in redis.go

GeoRadius see comment in redis.go

GeoRadiusByMember see comment in redis.go

GetRange see redis command

HExists see redis command

HGetAll see redis command

HIncrBy see redis command

HIncrByFloat see redis command

HScan see comment in redis.go

IncrByFloat see redis command

LInsert see comment in redis.go

LPushX see comment in redis.go

MGet see comment in redis.go

MSet see comment in redis.go

MSetNx see comment in redis.go

PExpire see redis command

PExpireAt see redis command

PSubscribe see redis command

Persist see redis command

PfAdd see comment in redis.go

PfCount see redis command

PfMerge see redis command

Publish see redis command

RPopLPush see comment in redis.go

RPushX see comment in redis.go

Rename see comment in redis.go

RenameNx see comment in redis.go

SCard see comment in redis.go

SDiff see comment in redis.go

SDiffStore see comment in redis.go

SInter see comment in redis.go

SInterStore see comment in redis.go

SIsMember see comment in redis.go

SMembers see redis command

SMove see comment in redis.go

SPopBatch see comment in redis.go

func (*RedisCluster) SRandMember added in v0.0.11

SRandMember see comment in redis.go

func (*RedisCluster) SRandMemberBatch added in v0.0.11

SRandMemberBatch see comment in redis.go

SScan see comment in redis.go

SUnion see comment in redis.go

SUnionStore see comment in redis.go

ScriptExists see redis command

ScriptLoad see redis command

Set set key/value,without timeout

SetBitWithBool see redis command

SetRange see redis command

SetWithParams see redis command

Sort see comment in redis.go

SortStore see comment in redis.go

StrLen see comment in redis.go

Subscribe see redis command

ZAdd see comment in redis.go

ZAddByMap see comment in redis.go

ZCard see comment in redis.go

ZCount see comment in redis.go

ZIncrBy see comment in redis.go

ZInterStore see comment in redis.go

ZInterStoreWithParams see redis command

ZLexCount see comment in redis.go

ZRange see comment in redis.go

ZRangeByLex see comment in redis.go

ZRangeByLexBatch see comment in redis.go

ZRangeByScore see comment in redis.go

ZRangeByScoreBatch see comment in redis.go

ZRangeByScoreWithScores see comment in redis.go

ZRangeByScoreWithScoresBatch see comment in redis.go

ZRangeWithScores see comment in redis.go

ZRank see comment in redis.go

ZRem see comment in redis.go

ZRemRangeByLex see comment in redis.go

ZRemRangeByRank see comment in redis.go

ZRemRangeByScore see comment in redis.go

ZRevRange see comment in redis.go

ZRevRangeByLex see comment in redis.go

ZRevRangeByLexBatch see comment in redis.go

ZRevRangeByScore see comment in redis.go

ZRevRangeByScoreWithScores see comment in redis.go

ZRevRangeByScoreWithScoresBatch see comment in redis.go

ZRevRangeWithScores see comment in redis.go

ZRevRank see comment in redis.go

ZScan see comment in redis.go

ZScore see comment in redis.go

ZUnionStore see redis command

ZUnionStoreWithParams see redis command

type RedisError struct {
	Message string
}

RedisError basic redis error

type RedisPubSub struct {
	OnMessage      func(channel, message string)                 
	OnPMessage     func(pattern string, channel, message string) 
	OnSubscribe    func(channel string, subscribedChannels int)  
	OnUnSubscribe  func(channel string, subscribedChannels int)  
	OnPUnSubscribe func(pattern string, subscribedChannels int)  
	OnPSubscribe   func(pattern string, subscribedChannels int)  
	OnPong         func(channel string)                          
	
}

RedisPubSub redis pubsub struct

PSubscribe subscribe some pattern channels

PUnSubscribe unsubscribe some pattern channels

Subscribe subscribe some channels

UnSubscribe unsubscribe some channels

Response pipeline and transaction response,include replies from redis

func (r *Response) Get() (interface{}, error)

Get get real content of response

type ScanParams struct {
	
}

ScanParams scan,hscan,sscan,zscan params

func NewScanParams() *ScanParams

NewScanParams create scan params instance

func (s *ScanParams) Count(count int) *ScanParams

Count scan result count

GetMatch get the match param value

ScanResult scan result struct

func ObjArrToScanResultReply(reply []interface{}, err error) (*ScanResult, error)

ObjArrToScanResultReply convert object array reply to scanresult reply

func ToScanResultReply(reply interface{}, err error) (*ScanResult, error)

ToScanResultReply convert object reply to scanresult reply

SlowLog redis slow log struct

type SortParams struct {
	
}

SortParams sort params

func NewSortParams() *SortParams

NewSortParams create new sort params instance

func (p *SortParams) Alpha() *SortParams

Alpha sort elements in alpha order

func (p *SortParams) Asc() *SortParams

Asc set asc param,then sort elements in ascending order

By set by param with pattern

func (p *SortParams) Desc() *SortParams

Desc set desc param,then sort elements in descending order

Get set get param with patterns

func (p *SortParams) Limit(start, count int) *SortParams

Limit limit the sort result,[x,y)

func (p *SortParams) NoSort() *SortParams

NoSort set by param with nosort

type Transaction struct {
	
}

Transaction redis transaction struct

BLPopTimeout see redis command

func (p Transaction) BRPopLPush(source, destination string, timeout int) (*Response, error)

BRPopLPush see redis command

BRPopTimeout see redis command

func (p Transaction) BgRewriteAof() (*Response, error)

BgRewriteAof see redis command

func (p Transaction) BgSave() (*Response, error)

BgSave see redis command

func (p Transaction) ClusterAddSlots(slots ...int) (*Response, error)

ClusterAddSlots see redis command

func (p Transaction) ClusterDelSlots(slots ...int) (*Response, error)

ClusterDelSlots see redis command

func (p Transaction) ClusterGetKeysInSlot(slot int, count int) (*Response, error)

ClusterGetKeysInSlot see redis command

func (p Transaction) ClusterInfo() (*Response, error)

ClusterInfo see redis command

ClusterMeet see redis command

func (p Transaction) ClusterNodes() (*Response, error)

ClusterNodes see redis command

func (p Transaction) ClusterSetSlotImporting(slot int, nodeID string) (*Response, error)

ClusterSetSlotImporting see redis command

func (p Transaction) ClusterSetSlotMigrating(slot int, nodeID string) (*Response, error)

ClusterSetSlotMigrating see redis command

func (p Transaction) ClusterSetSlotNode(slot int, nodeID string) (*Response, error)

ClusterSetSlotNode see redis command

ConfigGet see redis command

func (p Transaction) ConfigResetStat() (*Response, error)

ConfigResetStat see redis command

func (p Transaction) ConfigSet(parameter, value string) (*Response, error)

ConfigSet see redis command

func (p Transaction) DbSize() (*Response, error)

DbSize see redis command

Discard see redis command

EvalSha see redis command

func (t *Transaction) Exec() ([]interface{}, error)

Exec execute transaction

func (t *Transaction) ExecGetResponse() ([]*Response, error)

ExecGetResponse ...

func (p Transaction) FlushAll() (*Response, error)

FlushAll see redis command

func (p Transaction) FlushDB() (*Response, error)

FlushDB see redis command

func (p Transaction) Info() (*Response, error)

Info see redis command

func (p Transaction) LastSave() (*Response, error)

LastSave see redis command

PfCount see redis command

PfMerge see redis command

func (p Transaction) Ping() (*Response, error)

Ping see redis command

func (p Transaction) Publish(channel, message string) (*Response, error)

Publish see redis command

func (p Transaction) RPopLPush(srcKey, destKey string) (*Response, error)

RPopLPush see redis command

func (Transaction) RandomKey added in v0.0.11

func (p Transaction) RandomKey() (*Response, error)

RandomKey see redis command

func (p Transaction) Rename(oldkey, newkey string) (*Response, error)

Rename see redis command

func (p Transaction) RenameNx(oldkey, newkey string) (*Response, error)

RenameNx see redis command

SDiffStore see redis command

SInterStore see redis command

func (p Transaction) SMove(srcKey, destKey, member string) (*Response, error)

SMove see redis command

SUnionStore see redis command

func (p Transaction) Save() (*Response, error)

Save see redis command

func (p Transaction) Select(index int) (*Response, error)

Select see redis command

func (p Transaction) Shutdown() (*Response, error)

Shutdown see redis command

SortMulti see redis command

func (p Transaction) Time() (*Response, error)

Time see redis command

ZInterStore see redis command

func (p Transaction) ZInterStoreWithParams(destKey string, params *ZParams, sets ...string) (*Response, error)

ZInterStoreWithParams see redis command

ZUnionStore see redis command

func (p Transaction) ZUnionStoreWithParams(destKey string, params *ZParams, sets ...string) (*Response, error)

ZUnionStoreWithParams see redis command

Tuple zset tuple

StrArrToTupleReply convert string array reply to tuple array reply

func ToTupleArrReply(reply interface{}, err error) ([]Tuple, error)

ToTupleArrReply convert object reply to tuple array reply

type ZAddParams struct {
	
}

ZAddParams ...

func NewZAddParams() *ZAddParams

NewZAddParams constructor

func (p *ZAddParams) CH() *ZAddParams

CH set CH parameter, Modify the return value from the number of new elements added, to the total number of elements changed

Contains return params map contains the key

func (p *ZAddParams) NX() *ZAddParams

NX set NX parameter, Don't update already existing elements. Always add new elements.

func (p *ZAddParams) XX() *ZAddParams

XX set XX parameter, Only update elements that already exist. Never add elements.

ZParams zset operation params

func (g *ZParams) Aggregate(aggregate *Aggregate) *ZParams

Aggregate Set Aggregate.

func (g *ZParams) WeightsByDouble(weights ...float64) *ZParams

WeightsByDouble Set weights.