Comredis v1.0.1 Comredis
Entry point module of the library with all Redis commands functions.
The functions defined here are loaded in compile time from the
Redis commands documentation
The only exceptions are commands/0, command_group/1 and command_groups/0
that provide a way to look for the desired commands.
Because you don’t need to remember all of them by heart
Summary
Functions
Append a value to a key
Authenticate to the server
Asynchronously rewrite the append-only file
Asynchronously save the dataset to disk
Count set bits in a string
Perform bitwise operations between strings
Find first bit set or clear in a string
Remove and get the first element in a list, or block until one is available
Remove and get the last element in a list, or block until one is available
Pop a value from a list, push it to another list and return it; or block until one is available
Get the current connection name
Kill the connection of a client
Get the list of client connections
Stop processing commands from clients for some time
Instruct the server whether to reply to commands
Set the current connection name
Assign new hash slots to receiving node
Return the number of failure reports active for a given node
Return the number of local keys in the specified hash slot
Set hash slots as unbound in receiving node
Forces a slave to perform a manual failover of its master
Remove a node from the nodes table
Return local key names in the specified hash slot
Provides info about Redis Cluster node state
Returns the hash slot of the specified key
Force a node cluster to handshake with another node
Get Cluster config for the node
Reconfigure a node as a slave of the specified master node
Reset a Redis Cluster node
Forces the node to save cluster state on disk
Set the configuration epoch in a new node
Bind a hash slot to a specific node
List slave nodes of the specified master node
Get array of Cluster slot to node mappings
Get array of Redis command details
Get total number of Redis commands
Extract keys given a full Redis command
Returns the commands in the given command group
Returns the names of the command groups provided by Redis
Get array of specific Redis command details
Returns the list of all available commands
Get the value of a configuration parameter
Reset the stats returned by INFO
Rewrite the configuration file with the in memory configuration
Set a configuration parameter to the given value
Return the number of keys in the selected database
Get debugging information about a key
Make the server crash
Decrement the integer value of a key by one
Decrement the integer value of a key by the given number
Delete a key
Discard all commands issued after MULTI
Return a serialized version of the value stored at the specified key
Echo the given string
Execute a Lua script server side
Execute a Lua script server side
Execute all commands issued after MULTI
Determine if a key exists
Set a key’s time to live in seconds
Set the expiration for a key as a UNIX timestamp
Remove all keys from all databases
Remove all keys from the current database
Add one or more geospatial items in the geospatial index represented using a sorted set
Returns the distance between two members of a geospatial index
Returns members of a geospatial index as standard geohash strings
Returns longitude and latitude of members of a geospatial index
Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point
Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member
Get the value of a key
Returns the bit value at offset in the string value stored at key
Get a substring of the string stored at a key
Set the string value of a key and return its old value
Delete one or more hash fields
Determine if a hash field exists
Get the value of a hash field
Get all the fields and values in a hash
Increment the integer value of a hash field by the given number
Increment the float value of a hash field by the given amount
Get all the fields in a hash
Get the number of fields in a hash
Get the values of all the given hash fields
Set multiple hash fields to multiple values
Incrementally iterate hash fields and associated values
Set the string value of a hash field
Set the value of a hash field, only if the field does not exist
Get the length of the value of a hash field
Get all the values in a hash
Increment the integer value of a key by one
Increment the integer value of a key by the given amount
Increment the float value of a key by the given amount
Get information and statistics about the server
Find all keys matching the given pattern
Get the UNIX time stamp of the last successful save to disk
Get an element from a list by its index
Insert an element before or after another element in a list
Get the length of a list
Remove and get the first element in a list
Prepend one or multiple values to a list
Prepend a value to a list, only if the list exists
Get a range of elements from a list
Remove elements from a list
Set the value of an element in a list by its index
Trim a list to the specified range
Get the values of all the given keys
Atomically transfer a key from a Redis instance to another one
Listen for all requests received by the server in real time
Move a key to another database
Set multiple keys to multiple values
Set multiple keys to multiple values, only if none of the keys exist
Mark the start of a transaction block
Inspect the internals of Redis objects
Remove the expiration from a key
Set a key’s time to live in milliseconds
Set the expiration for a key as a UNIX timestamp specified in milliseconds
Adds the specified elements to the specified HyperLogLog
Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s)
Merge N different HyperLogLogs into a single one
Ping the server
Set the value and expiration in milliseconds of a key
Listen for messages published to channels matching the given patterns
Get the time to live for a key in milliseconds
Post a message to a channel
Inspect the state of the Pub/Sub subsystem
Stop listening for messages posted to channels matching the given patterns
Close the connection
Return a random key from the keyspace
Enables read queries for a connection to a cluster slave node
Disables read queries for a connection to a cluster slave node
Rename a key
Rename a key, only if the new key does not exist
Create a key using the provided serialized value, previously obtained using DUMP
Return the role of the instance in the context of replication
Remove and get the last element in a list
Remove the last element in a list, prepend it to another list and return it
Append one or multiple values to a list
Append a value to a list, only if the list exists
Add one or more members to a set
Synchronously save the dataset to disk
Incrementally iterate the keys space
Get the number of members in a set
Set the debug mode for executed scripts
Check existence of scripts in the script cache
Remove all the scripts from the script cache
Kill the script currently in execution
Load the specified Lua script into the script cache
Subtract multiple sets
Subtract multiple sets and store the resulting set in a key
Change the selected database for the current connection
Set the string value of a key
Sets or clears the bit at offset in the string value stored at key
Set the value and expiration of a key
Set the value of a key, only if the key does not exist
Overwrite part of a string at key starting at the specified offset
Synchronously save the dataset to disk and then shut down the server
Intersect multiple sets
Intersect multiple sets and store the resulting set in a key
Determine if a given value is a member of a set
Make the server a slave of another instance, or promote it as master
Manages the Redis slow queries log
Get all the members in a set
Move a member from one set to another
Sort the elements in a list, set or sorted set
Remove and return one or multiple random members from a set
Get one or multiple random members from a set
Remove one or more members from a set
Incrementally iterate Set elements
Get the length of the value stored in a key
Listen for messages published to the given channels
Add multiple sets
Add multiple sets and store the resulting set in a key
Internal command used for replication
Return the current server time
Get the time to live for a key
Determine the type stored at key
Stop listening for messages posted to the given channels
Forget about all watched keys
Wait for the synchronous replication of all the write commands sent in the context of the current connection
Watch the given keys to determine execution of the MULTI/EXEC block
Add one or more members to a sorted set, or update its score if it already exists
Get the number of members in a sorted set
Count the members in a sorted set with scores within the given values
Increment the score of a member in a sorted set
Intersect multiple sorted sets and store the resulting sorted set in a new key
Count the number of members in a sorted set between a given lexicographical range
Return a range of members in a sorted set, by index
Return a range of members in a sorted set, by lexicographical range
Return a range of members in a sorted set, by score
Determine the index of a member in a sorted set
Remove one or more members from a sorted set
Remove all members in a sorted set between the given lexicographical range
Remove all members in a sorted set within the given indexes
Remove all members in a sorted set within the given scores
Return a range of members in a sorted set, by index, with scores ordered from high to low
Return a range of members in a sorted set, by lexicographical range, ordered from higher to lower strings
Return a range of members in a sorted set, by score, with scores ordered from high to low
Determine the index of a member in a sorted set, with scores ordered from high to low
Incrementally iterate sorted sets elements and associated scores
Get the score associated with the given member in a sorted set
Add multiple sorted sets and store the resulting sorted set in a new key
Functions
Append a value to a key
Group: string
Available since version 2.0.0.
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.
Arguments:
keyvaluestring
Authenticate to the server
Group: connection
Available since version 1.0.0.
Arguments:
passwordstring
Asynchronously rewrite the append-only file
Group: server
Available since version 1.0.0.
Count set bits in a string
Group: string
Available since version 2.6.0.
Time complexity: O(N)
Arguments:
keystart_endoptional, [integer, integer]
Perform bitwise operations between strings
Group: string
Available since version 2.6.0.
Time complexity: O(N)
Arguments:
operationstringdestkeykeykeymultiple
Find first bit set or clear in a string
Group: string
Available since version 2.8.7.
Time complexity: O(N)
Arguments:
keybitintegerstartoptional, integerendoptional, integer
Remove and get the first element in a list, or block until one is available
Group: list
Available since version 2.0.0.
Time complexity: O(1)
Arguments:
keymultipletimeoutinteger
Remove and get the last element in a list, or block until one is available
Group: list
Available since version 2.0.0.
Time complexity: O(1)
Arguments:
keymultipletimeoutinteger
Pop a value from a list, push it to another list and return it; or block until one is available
Group: list
Available since version 2.2.0.
Time complexity: O(1)
Arguments:
sourcekeydestinationkeytimeoutinteger
Get the current connection name
Group: server
Available since version 2.6.9.
Time complexity: O(1)
Kill the connection of a client
Group: server
Available since version 2.4.0.
Time complexity: O(N) where N is the number of client connections
Arguments:
ip_portoptional, stringidoptional, integertypeoptional, enum, ["normal", "master", "slave", "pubsub"]addroptional, stringskipmeoptional, string
Get the list of client connections
Group: server
Available since version 2.4.0.
Time complexity: O(N) where N is the number of client connections
Stop processing commands from clients for some time
Group: server
Available since version 2.9.50.
Time complexity: O(1)
Arguments:
timeoutinteger
Instruct the server whether to reply to commands
Group: server
Available since version 3.2.
Time complexity: O(1)
Arguments:
reply_modeenum, ["ON", "OFF", "SKIP"]
Set the current connection name
Group: server
Available since version 2.6.9.
Time complexity: O(1)
Arguments:
connection_namestring
Assign new hash slots to receiving node
Group: cluster
Available since version 3.0.0.
Time complexity: O(N) where N is the total number of hash slot arguments
Arguments:
slotmultiple, integer
Return the number of failure reports active for a given node
Group: cluster
Available since version 3.0.0.
Time complexity: O(N) where N is the number of failure reports
Arguments:
node_idstring
Return the number of local keys in the specified hash slot
Group: cluster
Available since version 3.0.0.
Time complexity: O(1)
Arguments:
slotinteger
Set hash slots as unbound in receiving node
Group: cluster
Available since version 3.0.0.
Time complexity: O(N) where N is the total number of hash slot arguments
Arguments:
slotmultiple, integer
Forces a slave to perform a manual failover of its master.
Group: cluster
Available since version 3.0.0.
Time complexity: O(1)
Arguments:
optionsoptional, enum, ["FORCE", "TAKEOVER"]
Remove a node from the nodes table
Group: cluster
Available since version 3.0.0.
Time complexity: O(1)
Arguments:
node_idstring
Return local key names in the specified hash slot
Group: cluster
Available since version 3.0.0.
Time complexity: O(log(N)) where N is the number of requested keys
Arguments:
slotintegercountinteger
Provides info about Redis Cluster node state
Group: cluster
Available since version 3.0.0.
Time complexity: O(1)
Returns the hash slot of the specified key
Group: cluster
Available since version 3.0.0.
Time complexity: O(N) where N is the number of bytes in the key
Arguments:
keystring
Force a node cluster to handshake with another node
Group: cluster
Available since version 3.0.0.
Time complexity: O(1)
Arguments:
ipstringportinteger
Get Cluster config for the node
Group: cluster
Available since version 3.0.0.
Time complexity: O(N) where N is the total number of Cluster nodes
Reconfigure a node as a slave of the specified master node
Group: cluster
Available since version 3.0.0.
Time complexity: O(1)
Arguments:
node_idstring
Reset a Redis Cluster node
Group: cluster
Available since version 3.0.0.
Time complexity: O(N) where N is the number of known nodes. The command may execute a FLUSHALL as a side effect.
Arguments:
reset_typeoptional, enum, ["HARD", "SOFT"]
Forces the node to save cluster state on disk
Group: cluster
Available since version 3.0.0.
Time complexity: O(1)
Set the configuration epoch in a new node
Group: cluster
Available since version 3.0.0.
Time complexity: O(1)
Arguments:
config_epochinteger
Bind a hash slot to a specific node
Group: cluster
Available since version 3.0.0.
Time complexity: O(1)
Arguments:
slotintegersubcommandenum, ["IMPORTING", "MIGRATING", "STABLE", "NODE"]node_idoptional, string
List slave nodes of the specified master node
Group: cluster
Available since version 3.0.0.
Time complexity: O(1)
Arguments:
node_idstring
Get array of Cluster slot to node mappings
Group: cluster
Available since version 3.0.0.
Time complexity: O(N) where N is the total number of Cluster nodes
Get array of Redis command details
Group: server
Available since version 2.8.13.
Time complexity: O(N) where N is the total number of Redis commands
Get total number of Redis commands
Group: server
Available since version 2.8.13.
Time complexity: O(1)
Extract keys given a full Redis command
Group: server
Available since version 2.8.13.
Time complexity: O(N) where N is the number of arguments to the command
Specs
command_group(atom) :: [atom]
Returns the commands in the given command group.
Specs
command_groups :: [atom]
Returns the names of the command groups provided by Redis.
Get array of specific Redis command details
Group: server
Available since version 2.8.13.
Time complexity: O(N) when N is number of commands to look up
Arguments:
command_namemultiple, string
Get the value of a configuration parameter
Group: server
Available since version 2.0.0.
Arguments:
parameterstring
Reset the stats returned by INFO
Group: server
Available since version 2.0.0.
Time complexity: O(1)
Rewrite the configuration file with the in memory configuration
Group: server
Available since version 2.8.0.
Set a configuration parameter to the given value
Group: server
Available since version 2.0.0.
Arguments:
parameterstringvaluestring
Return the number of keys in the selected database
Group: server
Available since version 1.0.0.
Get debugging information about a key
Group: server
Available since version 1.0.0.
Arguments:
key
Decrement the integer value of a key by one
Group: string
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
key
Decrement the integer value of a key by the given number
Group: string
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
keydecrementinteger
Delete a key
Group: generic
Available since version 1.0.0.
Time complexity: O(N) where N is the number of keys that will be removed. When a key to remove holds a value other than a string, the individual complexity for this key is O(M) where M is the number of elements in the list, set, sorted set or hash. Removing a single key that holds a string value is O(1).
Arguments:
keymultiple
Discard all commands issued after MULTI
Group: transactions
Available since version 2.0.0.
Return a serialized version of the value stored at the specified key.
Group: generic
Available since version 2.6.0.
Time complexity: O(1) to access the key and additional O(NM) to serialized it, where N is the number of Redis objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1M) where M is small, so simply O(1).
Arguments:
key
Echo the given string
Group: connection
Available since version 1.0.0.
Arguments:
messagestring
Execute a Lua script server side
Group: scripting
Available since version 2.6.0.
Time complexity: Depends on the script that is executed.
Arguments:
scriptstringnumkeysintegerkeymultipleargmultiple, string
Execute a Lua script server side
Group: scripting
Available since version 2.6.0.
Time complexity: Depends on the script that is executed.
Arguments:
sha1stringnumkeysintegerkeymultipleargmultiple, string
Determine if a key exists
Group: generic
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
keymultiple
Set a key’s time to live in seconds
Group: generic
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
keysecondsinteger
Set the expiration for a key as a UNIX timestamp
Group: generic
Available since version 1.2.0.
Time complexity: O(1)
Arguments:
keytimestampposix time
Add one or more geospatial items in the geospatial index represented using a sorted set
Group: geo
Time complexity: O(log(N)) for each item added, where N is the number of elements in the sorted set.
Arguments:
keylongitude_latitude_membermultiple, [double, double, string]
Returns the distance between two members of a geospatial index
Group: geo
Time complexity: O(log(N))
Arguments:
keymember1stringmember2stringunitoptional, string
Returns members of a geospatial index as standard geohash strings
Group: geo
Time complexity: O(log(N)) for each member requested, where N is the number of elements in the sorted set.
Arguments:
keymembermultiple, string
Returns longitude and latitude of members of a geospatial index
Group: geo
Time complexity: O(log(N)) for each member requested, where N is the number of elements in the sorted set.
Arguments:
keymembermultiple, string
Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point
Group: geo
Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.
Arguments:
keylongitudedoublelatitudedoubleradiusdoubleunitenum, ["m", "km", "ft", "mi"]withcoordoptional, enum, ["WITHCOORD"]withdistoptional, enum, ["WITHDIST"]withhashoptional, enum, ["WITHHASH"]countoptional, integer
Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member
Group: geo
Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.
Arguments:
keymemberstringradiusdoubleunitenum, ["m", "km", "ft", "mi"]withcoordoptional, enum, ["WITHCOORD"]withdistoptional, enum, ["WITHDIST"]withhashoptional, enum, ["WITHHASH"]countoptional, integer
Get the value of a key
Group: string
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
key
Returns the bit value at offset in the string value stored at key
Group: string
Available since version 2.2.0.
Time complexity: O(1)
Arguments:
keyoffsetinteger
Get a substring of the string stored at a key
Group: string
Available since version 2.4.0.
Time complexity: O(N) where N is the length of the returned string. The complexity is ultimately determined by the returned length, but because creating a substring from an existing string is very cheap, it can be considered O(1) for small strings.
Arguments:
keystartintegerendinteger
Set the string value of a key and return its old value
Group: string
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
keyvaluestring
Delete one or more hash fields
Group: hash
Available since version 2.0.0.
Time complexity: O(N) where N is the number of fields to be removed.
Arguments:
keyfieldmultiple, string
Determine if a hash field exists
Group: hash
Available since version 2.0.0.
Time complexity: O(1)
Arguments:
keyfieldstring
Get the value of a hash field
Group: hash
Available since version 2.0.0.
Time complexity: O(1)
Arguments:
keyfieldstring
Get all the fields and values in a hash
Group: hash
Available since version 2.0.0.
Time complexity: O(N) where N is the size of the hash.
Arguments:
key
Increment the integer value of a hash field by the given number
Group: hash
Available since version 2.0.0.
Time complexity: O(1)
Arguments:
keyfieldstringincrementinteger
Increment the float value of a hash field by the given amount
Group: hash
Available since version 2.6.0.
Time complexity: O(1)
Arguments:
keyfieldstringincrementdouble
Get all the fields in a hash
Group: hash
Available since version 2.0.0.
Time complexity: O(N) where N is the size of the hash.
Arguments:
key
Get the number of fields in a hash
Group: hash
Available since version 2.0.0.
Time complexity: O(1)
Arguments:
key
Get the values of all the given hash fields
Group: hash
Available since version 2.0.0.
Time complexity: O(N) where N is the number of fields being requested.
Arguments:
keyfieldmultiple, string
Set multiple hash fields to multiple values
Group: hash
Available since version 2.0.0.
Time complexity: O(N) where N is the number of fields being set.
Arguments:
keyfield_valuemultiple, [string, string]
Incrementally iterate hash fields and associated values
Group: hash
Available since version 2.8.0.
Time complexity: O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection..
Arguments:
keycursorintegermatchoptionalcountoptional, integer
Set the string value of a hash field
Group: hash
Available since version 2.0.0.
Time complexity: O(1)
Arguments:
keyfieldstringvaluestring
Set the value of a hash field, only if the field does not exist
Group: hash
Available since version 2.0.0.
Time complexity: O(1)
Arguments:
keyfieldstringvaluestring
Get the length of the value of a hash field
Group: hash
Available since version 3.2.0.
Time complexity: O(1)
Arguments:
keyfieldstring
Get all the values in a hash
Group: hash
Available since version 2.0.0.
Time complexity: O(N) where N is the size of the hash.
Arguments:
key
Increment the integer value of a key by one
Group: string
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
key
Increment the integer value of a key by the given amount
Group: string
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
keyincrementinteger
Increment the float value of a key by the given amount
Group: string
Available since version 2.6.0.
Time complexity: O(1)
Arguments:
keyincrementdouble
Get information and statistics about the server
Group: server
Available since version 1.0.0.
Arguments:
sectionoptional, string
Find all keys matching the given pattern
Group: generic
Available since version 1.0.0.
Time complexity: O(N) with N being the number of keys in the database, under the assumption that the key names in the database and the given pattern have limited length.
Arguments:
pattern
Get the UNIX time stamp of the last successful save to disk
Group: server
Available since version 1.0.0.
Get an element from a list by its index
Group: list
Available since version 1.0.0.
Time complexity: O(N) where N is the number of elements to traverse to get to the element at index. This makes asking for the first or the last element of the list O(1).
Arguments:
keyindexinteger
Insert an element before or after another element in a list
Group: list
Available since version 2.2.0.
Time complexity: O(N) where N is the number of elements to traverse before seeing the value pivot. This means that inserting somewhere on the left end on the list (head) can be considered O(1) and inserting somewhere on the right end (tail) is O(N).
Arguments:
keywhereenum, ["BEFORE", "AFTER"]pivotstringvaluestring
Get the length of a list
Group: list
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
key
Remove and get the first element in a list
Group: list
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
key
Prepend one or multiple values to a list
Group: list
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
keyvaluemultiple, string
Prepend a value to a list, only if the list exists
Group: list
Available since version 2.2.0.
Time complexity: O(1)
Arguments:
keyvaluestring
Get a range of elements from a list
Group: list
Available since version 1.0.0.
Time complexity: O(S+N) where S is the distance of start offset from HEAD for small lists, from nearest end (HEAD or TAIL) for large lists; and N is the number of elements in the specified range.
Arguments:
keystartintegerstopinteger
Remove elements from a list
Group: list
Available since version 1.0.0.
Time complexity: O(N) where N is the length of the list.
Arguments:
keycountintegervaluestring
Set the value of an element in a list by its index
Group: list
Available since version 1.0.0.
Time complexity: O(N) where N is the length of the list. Setting either the first or the last element of the list is O(1).
Arguments:
keyindexintegervaluestring
Trim a list to the specified range
Group: list
Available since version 1.0.0.
Time complexity: O(N) where N is the number of elements to be removed by the operation.
Arguments:
keystartintegerstopinteger
Get the values of all the given keys
Group: string
Available since version 1.0.0.
Time complexity: O(N) where N is the number of keys to retrieve.
Arguments:
keymultiple
Atomically transfer a key from a Redis instance to another one.
Group: generic
Available since version 2.6.0.
Time complexity: This command actually executes a DUMP+DEL in the source instance, and a RESTORE in the target instance. See the pages of these commands for time complexity. Also an O(N) data transfer between the two instances is performed.
Arguments:
hoststringportstringkeyenum, ["key", "\"\""]destination_dbintegertimeoutintegercopyoptional, enum, ["COPY"]replaceoptional, enum, ["REPLACE"]keysoptional
Listen for all requests received by the server in real time
Group: server
Available since version 1.0.0.
Move a key to another database
Group: generic
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
keydbinteger
Set multiple keys to multiple values
Group: string
Available since version 1.0.1.
Time complexity: O(N) where N is the number of keys to set.
Arguments:
key_valuemultiple, [key, string]
Set multiple keys to multiple values, only if none of the keys exist
Group: string
Available since version 1.0.1.
Time complexity: O(N) where N is the number of keys to set.
Arguments:
key_valuemultiple, [key, string]
Inspect the internals of Redis objects
Group: generic
Available since version 2.2.3.
Time complexity: O(1) for all the currently implemented subcommands.
Arguments:
subcommandstringargumentsoptional, multiple, string
Remove the expiration from a key
Group: generic
Available since version 2.2.0.
Time complexity: O(1)
Arguments:
key
Set a key’s time to live in milliseconds
Group: generic
Available since version 2.6.0.
Time complexity: O(1)
Arguments:
keymillisecondsinteger
Set the expiration for a key as a UNIX timestamp specified in milliseconds
Group: generic
Available since version 2.6.0.
Time complexity: O(1)
Arguments:
keymilliseconds_timestampposix time
Adds the specified elements to the specified HyperLogLog.
Group: hyperloglog
Available since version 2.8.9.
Time complexity: O(1) to add every element.
Arguments:
keyelementmultiple, string
Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s).
Group: hyperloglog
Available since version 2.8.9.
Time complexity: O(1) with every small average constant times when called with a single key. O(N) with N being the number of keys, and much bigger constant times, when called with multiple keys.
Arguments:
keymultiple
Merge N different HyperLogLogs into a single one.
Group: hyperloglog
Available since version 2.8.9.
Time complexity: O(N) to merge N HyperLogLogs, but with high constant times.
Arguments:
destkeykeysourcekeymultiple, key
Set the value and expiration in milliseconds of a key
Group: string
Available since version 2.6.0.
Time complexity: O(1)
Arguments:
keymillisecondsintegervaluestring
Listen for messages published to channels matching the given patterns
Group: pubsub
Available since version 2.0.0.
Time complexity: O(N) where N is the number of patterns the client is already subscribed to.
Arguments:
patternmultiple
Get the time to live for a key in milliseconds
Group: generic
Available since version 2.6.0.
Time complexity: O(1)
Arguments:
key
Post a message to a channel
Group: pubsub
Available since version 2.0.0.
Time complexity: O(N+M) where N is the number of clients subscribed to the receiving channel and M is the total number of subscribed patterns (by any client).
Arguments:
channelstringmessagestring
Inspect the state of the Pub/Sub subsystem
Group: pubsub
Available since version 2.8.0.
Time complexity: O(N) for the CHANNELS subcommand, where N is the number of active channels, and assuming constant time pattern matching (relatively short channels and patterns). O(N) for the NUMSUB subcommand, where N is the number of requested channels. O(1) for the NUMPAT subcommand.
Arguments:
subcommandstringargumentoptional, multiple, string
Stop listening for messages posted to channels matching the given patterns
Group: pubsub
Available since version 2.0.0.
Time complexity: O(N+M) where N is the number of patterns the client is already subscribed and M is the number of total patterns subscribed in the system (by any client).
Arguments:
patternoptional, multiple
Return a random key from the keyspace
Group: generic
Available since version 1.0.0.
Time complexity: O(1)
Enables read queries for a connection to a cluster slave node
Group: cluster
Available since version 3.0.0.
Time complexity: O(1)
Disables read queries for a connection to a cluster slave node
Group: cluster
Available since version 3.0.0.
Time complexity: O(1)
Rename a key
Group: generic
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
keynewkeykey
Rename a key, only if the new key does not exist
Group: generic
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
keynewkeykey
Create a key using the provided serialized value, previously obtained using DUMP.
Group: generic
Available since version 2.6.0.
Time complexity: O(1) to create the new key and additional O(NM) to reconstruct the serialized value, where N is the number of Redis objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1M) where M is small, so simply O(1). However for sorted set values the complexity is O(NMlog(N)) because inserting values into sorted sets is O(log(N)).
Arguments:
keyttlintegerserialized_valuestringreplaceoptional, enum, ["REPLACE"]
Return the role of the instance in the context of replication
Group: server
Available since version 2.8.12.
Remove and get the last element in a list
Group: list
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
key
Remove the last element in a list, prepend it to another list and return it
Group: list
Available since version 1.2.0.
Time complexity: O(1)
Arguments:
sourcekeydestinationkey
Append one or multiple values to a list
Group: list
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
keyvaluemultiple, string
Append a value to a list, only if the list exists
Group: list
Available since version 2.2.0.
Time complexity: O(1)
Arguments:
keyvaluestring
Add one or more members to a set
Group: set
Available since version 1.0.0.
Time complexity: O(N) where N is the number of members to be added.
Arguments:
keymembermultiple, string
Incrementally iterate the keys space
Group: generic
Available since version 2.8.0.
Time complexity: O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection.
Arguments:
cursorintegermatchoptionalcountoptional, integer
Get the number of members in a set
Group: set
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
key
Set the debug mode for executed scripts.
Group: scripting
Available since version 3.2.0.
Time complexity: O(1)
Arguments:
modeenum, ["YES", "SYNC", "NO"]
Check existence of scripts in the script cache.
Group: scripting
Available since version 2.6.0.
Time complexity: O(N) with N being the number of scripts to check (so checking a single script is an O(1) operation).
Arguments:
scriptmultiple, string
Remove all the scripts from the script cache.
Group: scripting
Available since version 2.6.0.
Time complexity: O(N) with N being the number of scripts in cache
Kill the script currently in execution.
Group: scripting
Available since version 2.6.0.
Time complexity: O(1)
Load the specified Lua script into the script cache.
Group: scripting
Available since version 2.6.0.
Time complexity: O(N) with N being the length in bytes of the script body.
Arguments:
scriptstring
Subtract multiple sets
Group: set
Available since version 1.0.0.
Time complexity: O(N) where N is the total number of elements in all given sets.
Arguments:
keymultiple
Subtract multiple sets and store the resulting set in a key
Group: set
Available since version 1.0.0.
Time complexity: O(N) where N is the total number of elements in all given sets.
Arguments:
destinationkeykeymultiple
Change the selected database for the current connection
Group: connection
Available since version 1.0.0.
Arguments:
indexinteger
Set the string value of a key
Group: string
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
keyvaluestringexoptional, integerpxoptional, integerconditionoptional, enum, ["NX", "XX"]
Sets or clears the bit at offset in the string value stored at key
Group: string
Available since version 2.2.0.
Time complexity: O(1)
Arguments:
keyoffsetintegervaluestring
Set the value and expiration of a key
Group: string
Available since version 2.0.0.
Time complexity: O(1)
Arguments:
keysecondsintegervaluestring
Set the value of a key, only if the key does not exist
Group: string
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
keyvaluestring
Overwrite part of a string at key starting at the specified offset
Group: string
Available since version 2.2.0.
Time complexity: O(1), not counting the time taken to copy the new string in place. Usually, this string is very small so the amortized complexity is O(1). Otherwise, complexity is O(M) with M being the length of the value argument.
Arguments:
keyoffsetintegervaluestring
Synchronously save the dataset to disk and then shut down the server
Group: server
Available since version 1.0.0.
Arguments:
save_modeoptional, enum, ["NOSAVE", "SAVE"]
Intersect multiple sets
Group: set
Available since version 1.0.0.
Time complexity: O(N*M) worst case where N is the cardinality of the smallest set and M is the number of sets.
Arguments:
keymultiple
Intersect multiple sets and store the resulting set in a key
Group: set
Available since version 1.0.0.
Time complexity: O(N*M) worst case where N is the cardinality of the smallest set and M is the number of sets.
Arguments:
destinationkeykeymultiple
Determine if a given value is a member of a set
Group: set
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
keymemberstring
Make the server a slave of another instance, or promote it as master
Group: server
Available since version 1.0.0.
Arguments:
hoststringportstring
Manages the Redis slow queries log
Group: server
Available since version 2.2.12.
Arguments:
subcommandstringargumentoptional, string
Get all the members in a set
Group: set
Available since version 1.0.0.
Time complexity: O(N) where N is the set cardinality.
Arguments:
key
Move a member from one set to another
Group: set
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
sourcekeydestinationkeymemberstring
Sort the elements in a list, set or sorted set
Group: generic
Available since version 1.0.0.
Time complexity: O(N+M*log(M)) where N is the number of elements in the list or set to sort, and M the number of returned elements. When the elements are not sorted, complexity is currently O(N) as there is a copy step that will be avoided in next releases.
Arguments:
keybyoptionallimitoptional, [integer, integer]getoptional, multiple, stringorderoptional, enum, ["ASC", "DESC"]sortingoptional, enum, ["ALPHA"]storeoptional, key
Remove and return one or multiple random members from a set
Group: set
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
keycountoptional, integer
Get one or multiple random members from a set
Group: set
Available since version 1.0.0.
Time complexity: Without the count argument O(1), otherwise O(N) where N is the absolute value of the passed count.
Arguments:
keycountoptional, integer
Remove one or more members from a set
Group: set
Available since version 1.0.0.
Time complexity: O(N) where N is the number of members to be removed.
Arguments:
keymembermultiple, string
Incrementally iterate Set elements
Group: set
Available since version 2.8.0.
Time complexity: O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection..
Arguments:
keycursorintegermatchoptionalcountoptional, integer
Get the length of the value stored in a key
Group: string
Available since version 2.2.0.
Time complexity: O(1)
Arguments:
key
Listen for messages published to the given channels
Group: pubsub
Available since version 2.0.0.
Time complexity: O(N) where N is the number of channels to subscribe to.
Arguments:
channelmultiple, [string]
Add multiple sets
Group: set
Available since version 1.0.0.
Time complexity: O(N) where N is the total number of elements in all given sets.
Arguments:
keymultiple
Add multiple sets and store the resulting set in a key
Group: set
Available since version 1.0.0.
Time complexity: O(N) where N is the total number of elements in all given sets.
Arguments:
destinationkeykeymultiple
Return the current server time
Group: server
Available since version 2.6.0.
Time complexity: O(1)
Get the time to live for a key
Group: generic
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
key
Determine the type stored at key
Group: generic
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
key
Stop listening for messages posted to the given channels
Group: pubsub
Available since version 2.0.0.
Time complexity: O(N) where N is the number of clients already subscribed to a channel.
Arguments:
channeloptional, multiple, string
Forget about all watched keys
Group: transactions
Available since version 2.2.0.
Time complexity: O(1)
Wait for the synchronous replication of all the write commands sent in the context of the current connection
Group: generic
Available since version 3.0.0.
Time complexity: O(1)
Arguments:
numslavesintegertimeoutinteger
Watch the given keys to determine execution of the MULTI/EXEC block
Group: transactions
Available since version 2.2.0.
Time complexity: O(1) for every key.
Arguments:
keymultiple
Add one or more members to a sorted set, or update its score if it already exists
Group: sorted_set
Available since version 1.2.0.
Time complexity: O(log(N)) for each item added, where N is the number of elements in the sorted set.
Arguments:
keyconditionoptional, enum, ["NX", "XX"]changeoptional, enum, ["CH"]incrementoptional, enum, ["INCR"]score_membermultiple, [double, string]
Get the number of members in a sorted set
Group: sorted_set
Available since version 1.2.0.
Time complexity: O(1)
Arguments:
key
Count the members in a sorted set with scores within the given values
Group: sorted_set
Available since version 2.0.0.
Time complexity: O(log(N)) with N being the number of elements in the sorted set.
Arguments:
keymindoublemaxdouble
Increment the score of a member in a sorted set
Group: sorted_set
Available since version 1.2.0.
Time complexity: O(log(N)) where N is the number of elements in the sorted set.
Arguments:
keyincrementintegermemberstring
Intersect multiple sorted sets and store the resulting sorted set in a new key
Group: sorted_set
Available since version 2.0.0.
Time complexity: O(NK)+O(Mlog(M)) worst case with N being the smallest input sorted set, K being the number of input sorted sets and M being the number of elements in the resulting sorted set.
Arguments:
destinationkeynumkeysintegerkeymultipleweightsoptional, integeraggregateoptional, enum, ["SUM", "MIN", "MAX"]
Count the number of members in a sorted set between a given lexicographical range
Group: sorted_set
Available since version 2.8.9.
Time complexity: O(log(N)) with N being the number of elements in the sorted set.
Arguments:
keyminstringmaxstring
Return a range of members in a sorted set, by index
Group: sorted_set
Available since version 1.2.0.
Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements returned.
Arguments:
keystartintegerstopintegerwithscoresoptional, enum, ["WITHSCORES"]
Return a range of members in a sorted set, by lexicographical range
Group: sorted_set
Available since version 2.8.9.
Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).
Arguments:
keyminstringmaxstringlimitoptional, [integer, integer]
Return a range of members in a sorted set, by score
Group: sorted_set
Available since version 1.0.5.
Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).
Arguments:
keymindoublemaxdoublewithscoresoptional, enum, ["WITHSCORES"]limitoptional, [integer, integer]
Determine the index of a member in a sorted set
Group: sorted_set
Available since version 2.0.0.
Time complexity: O(log(N))
Arguments:
keymemberstring
Remove one or more members from a sorted set
Group: sorted_set
Available since version 1.2.0.
Time complexity: O(M*log(N)) with N being the number of elements in the sorted set and M the number of elements to be removed.
Arguments:
keymembermultiple, string
Remove all members in a sorted set between the given lexicographical range
Group: sorted_set
Available since version 2.8.9.
Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements removed by the operation.
Arguments:
keyminstringmaxstring
Remove all members in a sorted set within the given indexes
Group: sorted_set
Available since version 2.0.0.
Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements removed by the operation.
Arguments:
keystartintegerstopinteger
Remove all members in a sorted set within the given scores
Group: sorted_set
Available since version 1.2.0.
Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements removed by the operation.
Arguments:
keymindoublemaxdouble
Return a range of members in a sorted set, by index, with scores ordered from high to low
Group: sorted_set
Available since version 1.2.0.
Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements returned.
Arguments:
keystartintegerstopintegerwithscoresoptional, enum, ["WITHSCORES"]
Return a range of members in a sorted set, by lexicographical range, ordered from higher to lower strings.
Group: sorted_set
Available since version 2.8.9.
Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).
Arguments:
keymaxstringminstringlimitoptional, [integer, integer]
Return a range of members in a sorted set, by score, with scores ordered from high to low
Group: sorted_set
Available since version 2.2.0.
Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).
Arguments:
keymaxdoublemindoublewithscoresoptional, enum, ["WITHSCORES"]limitoptional, [integer, integer]
Determine the index of a member in a sorted set, with scores ordered from high to low
Group: sorted_set
Available since version 2.0.0.
Time complexity: O(log(N))
Arguments:
keymemberstring
Incrementally iterate sorted sets elements and associated scores
Group: sorted_set
Available since version 2.8.0.
Time complexity: O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection..
Arguments:
keycursorintegermatchoptionalcountoptional, integer
Get the score associated with the given member in a sorted set
Group: sorted_set
Available since version 1.2.0.
Time complexity: O(1)
Arguments:
keymemberstring
Add multiple sorted sets and store the resulting sorted set in a new key
Group: sorted_set
Available since version 2.0.0.
Time complexity: O(N)+O(M log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set.
Arguments:
destinationkeynumkeysintegerkeymultipleweightsoptional, integeraggregateoptional, enum, ["SUM", "MIN", "MAX"]