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:
key
value
string
Authenticate to the server
Group: connection
Available since version 1.0.0.
Arguments:
password
string
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:
key
start_end
optional, [integer, integer]
Perform bitwise operations between strings
Group: string
Available since version 2.6.0.
Time complexity: O(N)
Arguments:
operation
stringdestkey
keykey
multiple
Find first bit set or clear in a string
Group: string
Available since version 2.8.7.
Time complexity: O(N)
Arguments:
key
bit
integerstart
optional, integerend
optional, 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:
key
multipletimeout
integer
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:
key
multipletimeout
integer
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:
source
keydestination
keytimeout
integer
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_port
optional, stringid
optional, integertype
optional, enum, ["normal", "master", "slave", "pubsub"]addr
optional, stringskipme
optional, 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:
timeout
integer
Instruct the server whether to reply to commands
Group: server
Available since version 3.2.
Time complexity: O(1)
Arguments:
reply_mode
enum, ["ON", "OFF", "SKIP"]
Set the current connection name
Group: server
Available since version 2.6.9.
Time complexity: O(1)
Arguments:
connection_name
string
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:
slot
multiple, 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_id
string
Return the number of local keys in the specified hash slot
Group: cluster
Available since version 3.0.0.
Time complexity: O(1)
Arguments:
slot
integer
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:
slot
multiple, 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:
options
optional, enum, ["FORCE", "TAKEOVER"]
Remove a node from the nodes table
Group: cluster
Available since version 3.0.0.
Time complexity: O(1)
Arguments:
node_id
string
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:
slot
integercount
integer
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:
key
string
Force a node cluster to handshake with another node
Group: cluster
Available since version 3.0.0.
Time complexity: O(1)
Arguments:
ip
stringport
integer
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_id
string
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_type
optional, 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_epoch
integer
Bind a hash slot to a specific node
Group: cluster
Available since version 3.0.0.
Time complexity: O(1)
Arguments:
slot
integersubcommand
enum, ["IMPORTING", "MIGRATING", "STABLE", "NODE"]node_id
optional, string
List slave nodes of the specified master node
Group: cluster
Available since version 3.0.0.
Time complexity: O(1)
Arguments:
node_id
string
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_name
multiple, string
Get the value of a configuration parameter
Group: server
Available since version 2.0.0.
Arguments:
parameter
string
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:
parameter
stringvalue
string
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:
key
decrement
integer
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:
key
multiple
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:
message
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:
script
stringnumkeys
integerkey
multiplearg
multiple, 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:
sha1
stringnumkeys
integerkey
multiplearg
multiple, string
Determine if a key exists
Group: generic
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
key
multiple
Set a key’s time to live in seconds
Group: generic
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
key
seconds
integer
Set the expiration for a key as a UNIX timestamp
Group: generic
Available since version 1.2.0.
Time complexity: O(1)
Arguments:
key
timestamp
posix 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:
key
longitude_latitude_member
multiple, [double, double, string]
Returns the distance between two members of a geospatial index
Group: geo
Time complexity: O(log(N))
Arguments:
key
member1
stringmember2
stringunit
optional, 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:
key
member
multiple, 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:
key
member
multiple, 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:
key
longitude
doublelatitude
doubleradius
doubleunit
enum, ["m", "km", "ft", "mi"]withcoord
optional, enum, ["WITHCOORD"]withdist
optional, enum, ["WITHDIST"]withhash
optional, enum, ["WITHHASH"]count
optional, 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:
key
member
stringradius
doubleunit
enum, ["m", "km", "ft", "mi"]withcoord
optional, enum, ["WITHCOORD"]withdist
optional, enum, ["WITHDIST"]withhash
optional, enum, ["WITHHASH"]count
optional, 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:
key
offset
integer
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:
key
start
integerend
integer
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:
key
value
string
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:
key
field
multiple, string
Determine if a hash field exists
Group: hash
Available since version 2.0.0.
Time complexity: O(1)
Arguments:
key
field
string
Get the value of a hash field
Group: hash
Available since version 2.0.0.
Time complexity: O(1)
Arguments:
key
field
string
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:
key
field
stringincrement
integer
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:
key
field
stringincrement
double
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:
key
field
multiple, 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:
key
field_value
multiple, [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:
key
cursor
integermatch
optionalcount
optional, integer
Set the string value of a hash field
Group: hash
Available since version 2.0.0.
Time complexity: O(1)
Arguments:
key
field
stringvalue
string
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:
key
field
stringvalue
string
Get the length of the value of a hash field
Group: hash
Available since version 3.2.0.
Time complexity: O(1)
Arguments:
key
field
string
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:
key
increment
integer
Increment the float value of a key by the given amount
Group: string
Available since version 2.6.0.
Time complexity: O(1)
Arguments:
key
increment
double
Get information and statistics about the server
Group: server
Available since version 1.0.0.
Arguments:
section
optional, 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:
key
index
integer
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:
key
where
enum, ["BEFORE", "AFTER"]pivot
stringvalue
string
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:
key
value
multiple, 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:
key
value
string
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:
key
start
integerstop
integer
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:
key
count
integervalue
string
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:
key
index
integervalue
string
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:
key
start
integerstop
integer
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:
key
multiple
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:
host
stringport
stringkey
enum, ["key", "\"\""]destination_db
integertimeout
integercopy
optional, enum, ["COPY"]replace
optional, enum, ["REPLACE"]keys
optional
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:
key
db
integer
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_value
multiple, [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_value
multiple, [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:
subcommand
stringarguments
optional, 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:
key
milliseconds
integer
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:
key
milliseconds_timestamp
posix 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:
key
element
multiple, 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:
key
multiple
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:
destkey
keysourcekey
multiple, key
Set the value and expiration in milliseconds of a key
Group: string
Available since version 2.6.0.
Time complexity: O(1)
Arguments:
key
milliseconds
integervalue
string
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:
pattern
multiple
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:
channel
stringmessage
string
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:
subcommand
stringargument
optional, 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:
pattern
optional, 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:
key
newkey
key
Rename a key, only if the new key does not exist
Group: generic
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
key
newkey
key
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:
key
ttl
integerserialized_value
stringreplace
optional, 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:
source
keydestination
key
Append one or multiple values to a list
Group: list
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
key
value
multiple, 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:
key
value
string
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:
key
member
multiple, 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:
cursor
integermatch
optionalcount
optional, 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:
mode
enum, ["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:
script
multiple, 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:
script
string
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:
key
multiple
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:
destination
keykey
multiple
Change the selected database for the current connection
Group: connection
Available since version 1.0.0.
Arguments:
index
integer
Set the string value of a key
Group: string
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
key
value
stringex
optional, integerpx
optional, integercondition
optional, 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:
key
offset
integervalue
string
Set the value and expiration of a key
Group: string
Available since version 2.0.0.
Time complexity: O(1)
Arguments:
key
seconds
integervalue
string
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:
key
value
string
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:
key
offset
integervalue
string
Synchronously save the dataset to disk and then shut down the server
Group: server
Available since version 1.0.0.
Arguments:
save_mode
optional, 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:
key
multiple
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:
destination
keykey
multiple
Determine if a given value is a member of a set
Group: set
Available since version 1.0.0.
Time complexity: O(1)
Arguments:
key
member
string
Make the server a slave of another instance, or promote it as master
Group: server
Available since version 1.0.0.
Arguments:
host
stringport
string
Manages the Redis slow queries log
Group: server
Available since version 2.2.12.
Arguments:
subcommand
stringargument
optional, 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:
source
keydestination
keymember
string
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:
key
by
optionallimit
optional, [integer, integer]get
optional, multiple, stringorder
optional, enum, ["ASC", "DESC"]sorting
optional, enum, ["ALPHA"]store
optional, 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:
key
count
optional, 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:
key
count
optional, 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:
key
member
multiple, 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:
key
cursor
integermatch
optionalcount
optional, 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:
channel
multiple, [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:
key
multiple
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:
destination
keykey
multiple
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:
channel
optional, 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:
numslaves
integertimeout
integer
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:
key
multiple
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:
key
condition
optional, enum, ["NX", "XX"]change
optional, enum, ["CH"]increment
optional, enum, ["INCR"]score_member
multiple, [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:
key
min
doublemax
double
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:
key
increment
integermember
string
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:
destination
keynumkeys
integerkey
multipleweights
optional, integeraggregate
optional, 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:
key
min
stringmax
string
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:
key
start
integerstop
integerwithscores
optional, 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:
key
min
stringmax
stringlimit
optional, [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:
key
min
doublemax
doublewithscores
optional, enum, ["WITHSCORES"]limit
optional, [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:
key
member
string
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:
key
member
multiple, 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:
key
min
stringmax
string
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:
key
start
integerstop
integer
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:
key
min
doublemax
double
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:
key
start
integerstop
integerwithscores
optional, 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:
key
max
stringmin
stringlimit
optional, [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:
key
max
doublemin
doublewithscores
optional, enum, ["WITHSCORES"]limit
optional, [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:
key
member
string
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:
key
cursor
integermatch
optionalcount
optional, 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:
key
member
string
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:
destination
keynumkeys
integerkey
multipleweights
optional, integeraggregate
optional, enum, ["SUM", "MIN", "MAX"]