Redis Commands¶
The following functions can be used to replicate their equivalent Redis command. Generally they can be used as functions on your redis connection. For the simplest example, see below:
Getting and settings data in redis:
import redis
r = redis.Redis(decode_responses=True)
r.set('mykey', 'thevalueofmykey')
r.get('mykey')
-
class
redis.commands.core.CoreCommands[source]¶ A class containing all of the implemented redis commands. This class is to be used as a mixin.
-
acl_cat(category=None, **kwargs)¶ Returns a list of categories or commands within a category.
If
categoryis not supplied, returns a list of all categories. Ifcategoryis supplied, returns a list of all commands within that category.For more information check https://redis.io/commands/acl-cat
-
acl_deluser(*username, **kwargs)¶ Delete the ACL for the specified ``username``s
For more information check https://redis.io/commands/acl-deluser
-
acl_genpass(bits=None, **kwargs)¶ Generate a random password value. If
bitsis supplied then use this number of bits, rounded to the next multiple of 4. See: https://redis.io/commands/acl-genpass
-
acl_getuser(username, **kwargs)¶ Get the ACL details for the specified
username.If
usernamedoes not exist, return NoneFor more information check https://redis.io/commands/acl-getuser
-
acl_help(**kwargs)¶ The ACL HELP command returns helpful text describing the different subcommands.
For more information check https://redis.io/commands/acl-help
-
acl_list(**kwargs)¶ Return a list of all ACLs on the server
For more information check https://redis.io/commands/acl-list
-
acl_load(**kwargs)¶ Load ACL rules from the configured
aclfile.Note that the server must be configured with the
aclfiledirective to be able to load ACL rules from an aclfile.For more information check https://redis.io/commands/acl-load
-
acl_log(count=None, **kwargs)¶ Get ACL logs as a list. :param int count: Get logs[0:count]. :rtype: List.
For more information check https://redis.io/commands/acl-log
-
acl_log_reset(**kwargs)¶ Reset ACL logs. :rtype: Boolean.
For more information check https://redis.io/commands/acl-log
-
acl_save(**kwargs)¶ Save ACL rules to the configured
aclfile.Note that the server must be configured with the
aclfiledirective to be able to save ACL rules to an aclfile.For more information check https://redis.io/commands/acl-save
-
acl_setuser(username, enabled=False, nopass=False, passwords=None, hashed_passwords=None, categories=None, commands=None, keys=None, reset=False, reset_keys=False, reset_passwords=False, **kwargs)¶ Create or update an ACL user.
Create or update the ACL for
username. If the user already exists, the existing ACL is completely overwritten and replaced with the specified values.enabledis a boolean indicating whether the user should be allowed to authenticate or not. Defaults toFalse.nopassis a boolean indicating whether the can authenticate without a password. This cannot be True ifpasswordsare also specified.passwordsif specified is a list of plain text passwords to add to or remove from the user. Each password must be prefixed with a ‘+’ to add or a ‘-’ to remove. For convenience, the value ofpasswordscan be a simple prefixed string when adding or removing a single password.hashed_passwordsif specified is a list of SHA-256 hashed passwords to add to or remove from the user. Each hashed password must be prefixed with a ‘+’ to add or a ‘-’ to remove. For convenience, the value ofhashed_passwordscan be a simple prefixed string when adding or removing a single password.categoriesif specified is a list of strings representing category permissions. Each string must be prefixed with either a ‘+’ to add the category permission or a ‘-’ to remove the category permission.commandsif specified is a list of strings representing command permissions. Each string must be prefixed with either a ‘+’ to add the command permission or a ‘-’ to remove the command permission.keysif specified is a list of key patterns to grant the user access to. Keys patterns allow ‘*’ to support wildcard matching. For example, ‘*’ grants access to all keys while ‘cache:*’ grants access to all keys that are prefixed with ‘cache:’.keysshould not be prefixed with a ‘~’.resetis a boolean indicating whether the user should be fully reset prior to applying the new ACL. Setting this to True will remove all existing passwords, flags and privileges from the user and then apply the specified rules. If this is False, the user’s existing passwords, flags and privileges will be kept and any new specified rules will be applied on top.reset_keysis a boolean indicating whether the user’s key permissions should be reset prior to applying any new key permissions specified inkeys. If this is False, the user’s existing key permissions will be kept and any new specified key permissions will be applied on top.reset_passwordsis a boolean indicating whether to remove all existing passwords and the ‘nopass’ flag from the user prior to applying any new passwords specified in ‘passwords’ or ‘hashed_passwords’. If this is False, the user’s existing passwords and ‘nopass’ status will be kept and any new specified passwords or hashed_passwords will be applied on top.For more information check https://redis.io/commands/acl-setuser
-
acl_users(**kwargs)¶ Returns a list of all registered users on the server.
For more information check https://redis.io/commands/acl-users
-
acl_whoami(**kwargs)¶ Get the username for the current connection
For more information check https://redis.io/commands/acl-whoami
-
append(key, value)¶ Appends the string
valueto the value atkey. Ifkeydoesn’t already exist, create it with a value ofvalue. Returns the new length of the value atkey.For more information check https://redis.io/commands/append
-
bgrewriteaof(**kwargs)¶ Tell the Redis server to rewrite the AOF file from data in memory.
For more information check https://redis.io/commands/bgrewriteaof
-
bgsave(schedule=True, **kwargs)¶ Tell the Redis server to save its data to disk. Unlike save(), this method is asynchronous and returns immediately.
For more information check https://redis.io/commands/bgsave
-
bitcount(key, start=None, end=None)¶ Returns the count of set bits in the value of
key. Optionalstartandendparameters indicate which bytes to considerFor more information check https://redis.io/commands/bitcount
-
bitfield(key, default_overflow=None)¶ Return a BitFieldOperation instance to conveniently construct one or more bitfield operations on
key.For more information check https://redis.io/commands/bitfield
-
bitop(operation, dest, *keys)¶ Perform a bitwise operation using
operationbetweenkeysand store the result indest.For more information check https://redis.io/commands/bitop
-
bitpos(key, bit, start=None, end=None)¶ Return the position of the first bit set to 1 or 0 in a string.
startandenddefines search range. The range is interpreted as a range of bytes and not a range of bits, so start=0 and end=2 means to look at the first three bytes.For more information check https://redis.io/commands/bitpos
-
blmove(first_list, second_list, timeout, src='LEFT', dest='RIGHT')¶ Blocking version of lmove.
For more information check https://redis.io/commands/blmove
-
blpop(keys, timeout=0)¶ LPOP a value off of the first non-empty list named in the
keyslist.If none of the lists in
keyshas a value to LPOP, then block fortimeoutseconds, or until a value gets pushed on to one of the lists.If timeout is 0, then block indefinitely.
For more information check https://redis.io/commands/blpop
-
brpop(keys, timeout=0)¶ RPOP a value off of the first non-empty list named in the
keyslist.If none of the lists in
keyshas a value to RPOP, then block fortimeoutseconds, or until a value gets pushed on to one of the lists.If timeout is 0, then block indefinitely.
For more information check https://redis.io/commands/brpop
-
brpoplpush(src, dst, timeout=0)¶ Pop a value off the tail of
src, push it on the head ofdstand then return it.This command blocks until a value is in
srcor untiltimeoutseconds elapse, whichever is first. Atimeoutvalue of 0 blocks forever.For more information check https://redis.io/commands/brpoplpush
-
bzpopmax(keys, timeout=0)¶ ZPOPMAX a value off of the first non-empty sorted set named in the
keyslist.If none of the sorted sets in
keyshas a value to ZPOPMAX, then block fortimeoutseconds, or until a member gets added to one of the sorted sets.If timeout is 0, then block indefinitely.
For more information check https://redis.io/commands/bzpopmax
-
bzpopmin(keys, timeout=0)¶ ZPOPMIN a value off of the first non-empty sorted set named in the
keyslist.If none of the sorted sets in
keyshas a value to ZPOPMIN, then block fortimeoutseconds, or until a member gets added to one of the sorted sets.If timeout is 0, then block indefinitely.
For more information check https://redis.io/commands/bzpopmin
-
client_getname(**kwargs)¶ Returns the current connection name
For more information check https://redis.io/commands/client-getname
-
client_getredir(**kwargs)¶ Returns the ID (an integer) of the client to whom we are redirecting tracking notifications.
-
client_id(**kwargs)¶ Returns the current connection id
For more information check https://redis.io/commands/client-id
-
client_info(**kwargs)¶ Returns information and statistics about the current client connection.
For more information check https://redis.io/commands/client-info
-
client_kill(address, **kwargs)¶ Disconnects the client at
address(ip:port)For more information check https://redis.io/commands/client-kill
-
client_kill_filter(_id=None, _type=None, addr=None, skipme=None, laddr=None, user=None, **kwargs)¶ Disconnects client(s) using a variety of filter options :param id: Kills a client by its unique ID field :param type: Kills a client by type where type is one of ‘normal’, ‘master’, ‘slave’ or ‘pubsub’ :param addr: Kills a client by its ‘address:port’ :param skipme: If True, then the client calling the command will not get killed even if it is identified by one of the filter options. If skipme is not provided, the server defaults to skipme=True :param laddr: Kills a client by its ‘local (bind) address:port’ :param user: Kills a client for a specific user name
-
client_list(_type=None, client_id=[], **kwargs)¶ Returns a list of currently connected clients. If type of client specified, only that type will be returned. :param _type: optional. one of the client types (normal, master,
replica, pubsub)Parameters: client_id – optional. a list of client ids For more information check https://redis.io/commands/client-list
-
client_pause(timeout, all=True, **kwargs)¶ Suspend all the Redis clients for the specified amount of time :param timeout: milliseconds to pause clients
For more information check https://redis.io/commands/client-pause :param all: If true (default) all client commands are blocked.
otherwise, clients are only blocked if they attempt to execute a write command. For the WRITE mode, some commands have special behavior:
EVAL/EVALSHA: Will block client for all scripts. PUBLISH: Will block client. PFCOUNT: Will block client. WAIT: Acknowledgments will be delayed, so this command will appear blocked.
-
client_reply(reply, **kwargs)¶ Enable and disable redis server replies.
replyMust be ON OFF or SKIP,ON - The default most with server replies to commands OFF - Disable server responses to commands SKIP - Skip the response of the immediately following command.Note: When setting OFF or SKIP replies, you will need a client object with a timeout specified in seconds, and will need to catch the TimeoutError.
The test_client_reply unit test illustrates this, and conftest.py has a client with a timeout.
-
client_setname(name, **kwargs)¶ Sets the current connection name
For more information check https://redis.io/commands/client-setname
-
client_tracking(on=True, clientid=None, prefix=[], bcast=False, optin=False, optout=False, noloop=False, **kwargs)¶ Enables the tracking feature of the Redis server, that is used for server assisted client side caching.
onindicate for tracking on or tracking off. The dafualt is on.clientidsend invalidation messages to the connection with the specified ID.bcastenable tracking in broadcasting mode. In this mode invalidation messages are reported for all the prefixes specified, regardless of the keys requested by the connection.optinwhen broadcasting is NOT active, normally don’t track keys in read only commands, unless they are called immediately after a CLIENT CACHING yes command.optoutwhen broadcasting is NOT active, normally track keys in read only commands, unless they are called immediately after a CLIENT CACHING no command.noloopdon’t send notifications about keys modified by this connection itself.prefixfor broadcasting, register a given key prefix, so that notifications will be provided only for keys starting with this string.
-
client_tracking_off(clientid=None, prefix=[], bcast=False, optin=False, optout=False, noloop=False)¶ Turn off the tracking mode. For more information about the options look at client_tracking func.
-
client_tracking_on(clientid=None, prefix=[], bcast=False, optin=False, optout=False, noloop=False)¶ Turn on the tracking mode. For more information about the options look at client_tracking func.
-
client_trackinginfo(**kwargs)¶ Returns the information about the current client connection’s use of the server assisted client side cache.
-
client_unblock(client_id, error=False, **kwargs)¶ Unblocks a connection by its client id. If
erroris True, unblocks the client with a special error message. Iferroris False (default), the client is unblocked using the regular timeout mechanism.For more information check https://redis.io/commands/client-unblock
-
client_unpause(**kwargs)¶ Unpause all redis clients
For more information check https://redis.io/commands/client-unpause
-
command(**kwargs)¶ Returns dict reply of details about all Redis commands.
For more information check https://redis.io/commands/command
-
config_get(pattern='*', **kwargs)¶ Return a dictionary of configuration based on the
patternFor more information check https://redis.io/commands/config-get
-
config_resetstat(**kwargs)¶ Reset runtime statistics
For more information check https://redis.io/commands/config-resetstat
-
config_rewrite(**kwargs)¶ Rewrite config file with the minimal change to reflect running config.
For more information check https://redis.io/commands/config-rewrite
-
config_set(name, value, **kwargs)¶ Set config item
namewithvalueFor more information check https://redis.io/commands/config-set
-
copy(source, destination, destination_db=None, replace=False)¶ Copy the value stored in the
sourcekey to thedestinationkey.destination_dban alternative destination database. By default, thedestinationkey is created in the source Redis database.replacewhether thedestinationkey should be removed before copying the value to it. By default, the value is not copied if thedestinationkey already exists.For more information check https://redis.io/commands/copy
-
dbsize(**kwargs)¶ Returns the number of keys in the current database
For more information check https://redis.io/commands/dbsize
-
debug_object(key, **kwargs)¶ Returns version specific meta information about a given key
For more information check https://redis.io/commands/debug-object
-
decr(name, amount=1)¶ Decrements the value of
keybyamount. If no key exists, the value will be initialized as 0 -amountFor more information check https://redis.io/commands/decr
-
decrby(name, amount=1)¶ Decrements the value of
keybyamount. If no key exists, the value will be initialized as 0 -amountFor more information check https://redis.io/commands/decrby
-
delete(*names)¶ Delete one or more keys specified by
names
-
dump(name)¶ Return a serialized version of the value stored at the specified key. If key does not exist a nil bulk reply is returned.
For more information check https://redis.io/commands/dump
-
echo(value, **kwargs)¶ Echo the string back from the server
For more information check https://redis.io/commands/echo
-
eval(script, numkeys, *keys_and_args)¶ Execute the Lua
script, specifying thenumkeysthe script will touch and the key names and argument values inkeys_and_args. Returns the result of the script.In practice, use the object returned by
register_script. This function exists purely for Redis API completion.For more information check https://redis.io/commands/eval
-
evalsha(sha, numkeys, *keys_and_args)¶ Use the
shato execute a Lua script already registered via EVAL or SCRIPT LOAD. Specify thenumkeysthe script will touch and the key names and argument values inkeys_and_args. Returns the result of the script.In practice, use the object returned by
register_script. This function exists purely for Redis API completion.For more information check https://redis.io/commands/evalsha
-
exists(*names)¶ Returns the number of
namesthat existFor more information check https://redis.io/commands/exists
-
expire(name, time)¶ Set an expire flag on key
namefortimeseconds.timecan be represented by an integer or a Python timedelta object.For more information check https://redis.io/commands/expire
-
expireat(name, when)¶ Set an expire flag on key
name.whencan be represented as an integer indicating unix time or a Python datetime object.For more information check https://redis.io/commands/expireat
-
flushall(asynchronous=False, **kwargs)¶ Delete all keys in all databases on the current host.
asynchronousindicates whether the operation is executed asynchronously by the server.For more information check https://redis.io/commands/flushall
-
flushdb(asynchronous=False, **kwargs)¶ Delete all keys in the current database.
asynchronousindicates whether the operation is executed asynchronously by the server.For more information check https://redis.io/commands/flushdb
-
geoadd(name, values, nx=False, xx=False, ch=False)¶ Add the specified geospatial items to the specified key identified by the
nameargument. The Geospatial items are given as ordered members of thevaluesargument, each item or place is formed by the triad longitude, latitude and name.Note: You can use ZREM to remove elements.
nxforces ZADD to only create new elements and not to update scores for elements that already exist.xxforces ZADD to only update scores of elements that already exist. New elements will not be added.chmodifies the return value to be the numbers of elements changed. Changed elements include new elements that were added and elements whose scores changed.For more information check https://redis.io/commands/geoadd
-
geodist(name, place1, place2, unit=None)¶ Return the distance between
place1andplace2members of thenamekey. The units must be one of the following : m, km mi, ft. By default meters are used.For more information check https://redis.io/commands/geodist
-
geohash(name, *values)¶ Return the geo hash string for each item of
valuesmembers of the specified key identified by thenameargument.For more information check https://redis.io/commands/geohash
-
geopos(name, *values)¶ Return the positions of each item of
valuesas members of the specified key identified by thenameargument. Each position is represented by the pairs lon and lat.For more information check https://redis.io/commands/geopos
-
georadius(name, longitude, latitude, radius, unit=None, withdist=False, withcoord=False, withhash=False, count=None, sort=None, store=None, store_dist=None, any=False)¶ Return the members of the specified key identified by the
nameargument which are within the borders of the area specified with thelatitudeandlongitudelocation and the maximum distance from the center specified by theradiusvalue.The units must be one of the following : m, km mi, ft. By default
withdistindicates to return the distances of each place.withcoordindicates to return the latitude and longitude of each place.withhashindicates to return the geohash string of each place.countindicates to return the number of elements up to N.sortindicates to return the places in a sorted way, ASC for nearest to fairest and DESC for fairest to nearest.storeindicates to save the places names in a sorted set named with a specific key, each element of the destination sorted set is populated with the score got from the original geo sorted set.store_distindicates to save the places names in a sorted set named with a specific key, instead ofstorethe sorted set destination score is set with the distance.For more information check https://redis.io/commands/georadius
-
georadiusbymember(name, member, radius, unit=None, withdist=False, withcoord=False, withhash=False, count=None, sort=None, store=None, store_dist=None, any=False)¶ This command is exactly like
georadiuswith the sole difference that instead of taking, as the center of the area to query, a longitude and latitude value, it takes the name of a member already existing inside the geospatial index represented by the sorted set.For more information check https://redis.io/commands/georadiusbymember
-
geosearch(name, member=None, longitude=None, latitude=None, unit='m', radius=None, width=None, height=None, sort=None, count=None, any=False, withcoord=False, withdist=False, withhash=False)¶ Return the members of specified key identified by the
nameargument, which are within the borders of the area specified by a given shape. This command extends the GEORADIUS command, so in addition to searching within circular areas, it supports searching within rectangular areas. This command should be used in place of the deprecated GEORADIUS and GEORADIUSBYMEMBER commands.memberUse the position of the given existingmember in the sorted set. Can’t be given withlongitudeandlatitude.longitudeandlatitudeUse the position given by this coordinates. Can’t be given withmemberradiusSimilar to GEORADIUS, search inside circular area according the given radius. Can’t be given withheightandwidth.heightandwidthSearch inside an axis-aligned rectangle, determined by the given height and width. Can’t be given withradiusunitmust be one of the following : m, km, mi, ft. m for meters (the default value), km for kilometers, mi for miles and ft for feet.sortindicates to return the places in a sorted way, ASC for nearest to farest and DESC for farest to nearest.countlimit the results to the first count matching items.anyis set to True, the command will return as soon as enough matches are found. Can’t be provided withoutcountwithdistindicates to return the distances of each place.withcoordindicates to return the latitude and longitude of each place.withhashindicates to return the geohash string of each place.For more information check https://redis.io/commands/geosearch
-
geosearchstore(dest, name, member=None, longitude=None, latitude=None, unit='m', radius=None, width=None, height=None, sort=None, count=None, any=False, storedist=False)¶ This command is like GEOSEARCH, but stores the result in
dest. By default, it stores the results in the destination sorted set with their geospatial information. ifstore_distset to True, the command will stores the items in a sorted set populated with their distance from the center of the circle or box, as a floating-point number.For more information check https://redis.io/commands/geosearchstore
-
get(name)¶ Return the value at key
name, or None if the key doesn’t existFor more information check https://redis.io/commands/get
-
getbit(name, offset)¶ Returns a boolean indicating the value of
offsetinnameFor more information check https://redis.io/commands/getbit
-
getdel(name)¶ Get the value at key
nameand delete the key. This command is similar to GET, except for the fact that it also deletes the key on success (if and only if the key’s value type is a string).For more information check https://redis.io/commands/getdel
-
getex(name, ex=None, px=None, exat=None, pxat=None, persist=False)¶ Get the value of key and optionally set its expiration. GETEX is similar to GET, but is a write command with additional options. All time parameters can be given as datetime.timedelta or integers.
exsets an expire flag on keynameforexseconds.pxsets an expire flag on keynameforpxmilliseconds.exatsets an expire flag on keynameforexseconds, specified in unix time.pxatsets an expire flag on keynameforexmilliseconds, specified in unix time.persistremove the time to live associated withname.For more information check https://redis.io/commands/getex
-
getrange(key, start, end)¶ Returns the substring of the string value stored at
key, determined by the offsetsstartandend(both are inclusive)For more information check https://redis.io/commands/getrange
-
getset(name, value)¶ Sets the value at key
nametovalueand returns the old value at keynameatomically.As per Redis 6.2, GETSET is considered deprecated. Please use SET with GET parameter in new code.
For more information check https://redis.io/commands/getset
-
hdel(name, *keys)¶ Delete
keysfrom hashnameFor more information check https://redis.io/commands/hdel
-
hexists(name, key)¶ Returns a boolean indicating if
keyexists within hashnameFor more information check https://redis.io/commands/hexists
-
hget(name, key)¶ Return the value of
keywithin the hashnameFor more information check https://redis.io/commands/hget
-
hgetall(name)¶ Return a Python dict of the hash’s name/value pairs
For more information check https://redis.io/commands/hgetall
-
hincrby(name, key, amount=1)¶ Increment the value of
keyin hashnamebyamountFor more information check https://redis.io/commands/hincrby
-
hincrbyfloat(name, key, amount=1.0)¶ Increment the value of
keyin hashnameby floatingamountFor more information check https://redis.io/commands/hincrbyfloat
-
hkeys(name)¶ Return the list of keys within hash
nameFor more information check https://redis.io/commands/hkeys
-
hlen(name)¶ Return the number of elements in hash
nameFor more information check https://redis.io/commands/hlen
-
hmget(name, keys, *args)¶ Returns a list of values ordered identically to
keysFor more information check https://redis.io/commands/hmget
-
hmset(name, mapping)¶ Set key to value within hash
namefor each corresponding key and value from themappingdict.For more information check https://redis.io/commands/hmset
-
hrandfield(key, count=None, withvalues=False)¶ Return a random field from the hash value stored at key.
count: if the argument is positive, return an array of distinct fields. If called with a negative count, the behavior changes and the command is allowed to return the same field multiple times. In this case, the number of returned fields is the absolute value of the specified count. withvalues: The optional WITHVALUES modifier changes the reply so it includes the respective values of the randomly selected hash fields.
For more information check https://redis.io/commands/hrandfield
-
hscan(name, cursor=0, match=None, count=None)¶ Incrementally return key/value slices in a hash. Also return a cursor indicating the scan position.
matchallows for filtering the keys by patterncountallows for hint the minimum number of returnsFor more information check https://redis.io/commands/hscan
-
hscan_iter(name, match=None, count=None)¶ Make an iterator using the HSCAN command so that the client doesn’t need to remember the cursor position.
matchallows for filtering the keys by patterncountallows for hint the minimum number of returns
-
hset(name, key=None, value=None, mapping=None)¶ Set
keytovaluewithin hashname,mappingaccepts a dict of key/value pairs that will be added to hashname. Returns the number of fields that were added.For more information check https://redis.io/commands/hset
-
hsetnx(name, key, value)¶ Set
keytovaluewithin hashnameifkeydoes not exist. Returns 1 if HSETNX created a field, otherwise 0.For more information check https://redis.io/commands/hsetnx
-
hstrlen(name, key)¶ Return the number of bytes stored in the value of
keywithin hashnameFor more information check https://redis.io/commands/hstrlen
-
hvals(name)¶ Return the list of values within hash
nameFor more information check https://redis.io/commands/hvals
-
incr(name, amount=1)¶ Increments the value of
keybyamount. If no key exists, the value will be initialized asamountFor more information check https://redis.io/commands/incr
-
incrby(name, amount=1)¶ Increments the value of
keybyamount. If no key exists, the value will be initialized asamountFor more information check https://redis.io/commands/incrby
-
incrbyfloat(name, amount=1.0)¶ Increments the value at key
nameby floatingamount. If no key exists, the value will be initialized asamountFor more information check https://redis.io/commands/incrbyfloat
-
info(section=None, **kwargs)¶ Returns a dictionary containing information about the Redis server
The
sectionoption can be used to select a specific section of informationThe section option is not supported by older versions of Redis Server, and will generate ResponseError
For more information check https://redis.io/commands/info
-
keys(pattern='*', **kwargs)¶ Returns a list of keys matching
patternFor more information check https://redis.io/commands/keys
-
lastsave(**kwargs)¶ Return a Python datetime object representing the last time the Redis database was saved to disk
For more information check https://redis.io/commands/lastsave
-
lindex(name, index)¶ Return the item from list
nameat positionindexNegative indexes are supported and will return an item at the end of the list
For more information check https://redis.io/commands/lindex
-
linsert(name, where, refvalue, value)¶ Insert
valuein listnameeither immediately before or after [where]refvalueReturns the new length of the list on success or -1 if
refvalueis not in the list.For more information check https://redis.io/commands/linsert
-
llen(name)¶ Return the length of the list
nameFor more information check https://redis.io/commands/llen
-
lmove(first_list, second_list, src='LEFT', dest='RIGHT')¶ Atomically returns and removes the first/last element of a list, pushing it as the first/last element on the destination list. Returns the element being popped and pushed.
For more information check https://redis.io/commands/lmove
-
lolwut(*version_numbers, **kwargs)¶ Get the Redis version and a piece of generative computer art
-
lpop(name, count=None)¶ Removes and returns the first elements of the list
name.By default, the command pops a single element from the beginning of the list. When provided with the optional
countargument, the reply will consist of up to count elements, depending on the list’s length.For more information check https://redis.io/commands/lpop
-
lpos(name, value, rank=None, count=None, maxlen=None)¶ Get position of
valuewithin the listnameIf specified,
rankindicates the “rank” of the first element to return in case there are multiple copies ofvaluein the list. By default, LPOS returns the position of the first occurrence ofvaluein the list. Whenrank2, LPOS returns the position of the secondvaluein the list. Ifrankis negative, LPOS searches the list in reverse. For example, -1 would return the position of the last occurrence ofvalueand -2 would return the position of the next to last occurrence ofvalue.If specified,
countindicates that LPOS should return a list of up tocountpositions. Acountof 2 would return a list of up to 2 positions. Acountof 0 returns a list of all positions matchingvalue. Whencountis specified and butvaluedoes not exist in the list, an empty list is returned.If specified,
maxlenindicates the maximum number of list elements to scan. Amaxlenof 1000 will only return the position(s) of items within the first 1000 entries in the list. Amaxlenof 0 (the default) will scan the entire list.For more information check https://redis.io/commands/lpos
-
lpush(name, *values)¶ Push
valuesonto the head of the listnameFor more information check https://redis.io/commands/lpush
-
lpushx(name, *values)¶ Push
valueonto the head of the listnameifnameexistsFor more information check https://redis.io/commands/lpushx
-
lrange(name, start, end)¶ Return a slice of the list
namebetween positionstartandendstartandendcan be negative numbers just like Python slicing notationFor more information check https://redis.io/commands/lrange
-
lrem(name, count, value)¶ Remove the first
countoccurrences of elements equal tovaluefrom the list stored atname.- The count argument influences the operation in the following ways:
count > 0: Remove elements equal to value moving from head to tail. count < 0: Remove elements equal to value moving from tail to head. count = 0: Remove all elements equal to value.
For more information check https://redis.io/commands/lrem
-
lset(name, index, value)¶ Set
positionof listnametovalueFor more information check https://redis.io/commands/lset
-
ltrim(name, start, end)¶ Trim the list
name, removing all values not within the slice betweenstartandendstartandendcan be negative numbers just like Python slicing notationFor more information check https://redis.io/commands/ltrim
-
memory_malloc_stats(**kwargs)¶ Return an internal statistics report from the memory allocator.
-
memory_purge(**kwargs)¶ Attempts to purge dirty pages for reclamation by allocator
For more information check https://redis.io/commands/memory-purge
-
memory_stats(**kwargs)¶ Return a dictionary of memory stats
For more information check https://redis.io/commands/memory-stats
-
memory_usage(key, samples=None, **kwargs)¶ Return the total memory usage for key, its value and associated administrative overheads.
For nested data structures,
samplesis the number of elements to sample. If left unspecified, the server’s default is 5. Use 0 to sample all elements.For more information check https://redis.io/commands/memory-usage
-
mget(keys, *args)¶ Returns a list of values ordered identically to
keysFor more information check https://redis.io/commands/mget
-
migrate(host, port, keys, destination_db, timeout, copy=False, replace=False, auth=None, **kwargs)¶ Migrate 1 or more keys from the current Redis server to a different server specified by the
host,portanddestination_db.The
timeout, specified in milliseconds, indicates the maximum time the connection between the two servers can be idle before the command is interrupted.If
copyis True, the specifiedkeysare NOT deleted from the source server.If
replaceis True, this operation will overwrite the keys on the destination server if they exist.If
authis specified, authenticate to the destination server with the password provided.For more information check https://redis.io/commands/migrate
-
module_list()¶ Returns a list of dictionaries containing the name and version of all loaded modules.
For more information check https://redis.io/commands/module-list
-
module_load(path, *args)¶ Loads the module from
path. Passes all*argsto the module, during loading. RaisesModuleErrorif a module is not found atpath.For more information check https://redis.io/commands/module-load
-
module_unload(name)¶ Unloads the module
name. RaisesModuleErrorifnameis not in loaded modules.For more information check https://redis.io/commands/module-unload
-
move(name, db)¶ Moves the key
nameto a different Redis databasedbFor more information check https://redis.io/commands/move
-
mset(mapping)¶ Sets key/values based on a mapping. Mapping is a dictionary of key/value pairs. Both keys and values should be strings or types that can be cast to a string via str().
For more information check https://redis.io/commands/mset
-
msetnx(mapping)¶ Sets key/values based on a mapping if none of the keys are already set. Mapping is a dictionary of key/value pairs. Both keys and values should be strings or types that can be cast to a string via str(). Returns a boolean indicating if the operation was successful.
For more information check https://redis.io/commands/msetnx
-
object(infotype, key, **kwargs)¶ Return the encoding, idletime, or refcount about the key
-
persist(name)¶ Removes an expiration on
nameFor more information check https://redis.io/commands/persist
-
pexpire(name, time)¶ Set an expire flag on key
namefortimemilliseconds.timecan be represented by an integer or a Python timedelta object.For more information check https://redis.io/commands/pexpire
-
pexpireat(name, when)¶ Set an expire flag on key
name.whencan be represented as an integer representing unix time in milliseconds (unix time * 1000) or a Python datetime object.For more information check https://redis.io/commands/pexpireat
-
pfadd(name, *values)¶ Adds the specified elements to the specified HyperLogLog.
For more information check https://redis.io/commands/pfadd
-
pfcount(*sources)¶ Return the approximated cardinality of the set observed by the HyperLogLog at key(s).
For more information check https://redis.io/commands/pfcount
-
pfmerge(dest, *sources)¶ Merge N different HyperLogLogs into a single one.
For more information check https://redis.io/commands/pfmerge
-
ping(**kwargs)¶ Ping the Redis server
For more information check https://redis.io/commands/ping
-
psetex(name, time_ms, value)¶ Set the value of key
nametovaluethat expires intime_msmilliseconds.time_mscan be represented by an integer or a Python timedelta objectFor more information check https://redis.io/commands/psetex
-
psync(replicationid, offset)¶ Initiates a replication stream from the master. Newer version for sync.
For more information check https://redis.io/commands/sync
-
pttl(name)¶ Returns the number of milliseconds until the key
namewill expireFor more information check https://redis.io/commands/pttl
-
publish(channel, message, **kwargs)¶ Publish
messageonchannel. Returns the number of subscribers the message was delivered to.For more information check https://redis.io/commands/publish
-
pubsub_channels(pattern='*', **kwargs)¶ Return a list of channels that have at least one subscriber
For more information check https://redis.io/commands/pubsub-channels
-
pubsub_numpat(**kwargs)¶ Returns the number of subscriptions to patterns
For more information check https://redis.io/commands/pubsub-numpat
-
pubsub_numsub(*args, **kwargs)¶ Return a list of (channel, number of subscribers) tuples for each channel given in
*argsFor more information check https://redis.io/commands/pubsub-numsub
-
quit(**kwargs)¶ Ask the server to close the connection.
For more information check https://redis.io/commands/quit
-
randomkey(**kwargs)¶ Returns the name of a random key
For more information check https://redis.io/commands/randomkey
-
readonly(**kwargs)¶ Enables read queries for a connection to a Redis Cluster replica node.
For more information check https://redis.io/commands/readonly
-
readwrite(**kwargs)¶ Disables read queries for a connection to a Redis Cluster slave node.
For more information check https://redis.io/commands/readwrite
-
register_script(script)¶ Register a Lua
scriptspecifying thekeysit will touch. Returns a Script object that is callable and hides the complexity of deal with scripts, keys, and shas. This is the preferred way to work with Lua scripts.
-
rename(src, dst)¶ Rename key
srctodstFor more information check https://redis.io/commands/rename
-
renamenx(src, dst)¶ Rename key
srctodstifdstdoesn’t already existFor more information check https://redis.io/commands/renamenx
-
replicaof(*args, **kwargs)¶ Update the replication settings of a redis replica, on the fly. Examples of valid arguments include:
NO ONE (set no replication) host port (set to the host and port of a redis server)For more information check https://redis.io/commands/replicaof
-
reset()¶ Perform a full reset on the connection’s server side contenxt.
-
restore(name, ttl, value, replace=False, absttl=False, idletime=None, frequency=None)¶ Create a key using the provided serialized value, previously obtained using DUMP.
replaceallows an existing key onnameto be overridden. If it’s not specified an error is raised on collision.absttlif True, specifiedttlshould represent an absolute Unix timestamp in milliseconds in which the key will expire. (Redis 5.0 or greater).idletimeUsed for eviction, this is the number of seconds the key must be idle, prior to execution.frequencyUsed for eviction, this is the frequency counter of the object stored at the key, prior to execution.For more information check https://redis.io/commands/restore
-
role()¶ Provide information on the role of a Redis instance in the context of replication, by returning if the instance is currently a master, slave, or sentinel.
For more information check https://redis.io/commands/role
-
rpop(name, count=None)¶ Removes and returns the last elements of the list
name.By default, the command pops a single element from the end of the list. When provided with the optional
countargument, the reply will consist of up to count elements, depending on the list’s length.For more information check https://redis.io/commands/rpop
-
rpoplpush(src, dst)¶ RPOP a value off of the
srclist and atomically LPUSH it on to thedstlist. Returns the value.For more information check https://redis.io/commands/rpoplpush
-
rpush(name, *values)¶ Push
valuesonto the tail of the listnameFor more information check https://redis.io/commands/rpush
-
rpushx(name, value)¶ Push
valueonto the tail of the listnameifnameexistsFor more information check https://redis.io/commands/rpushx
-
sadd(name, *values)¶ Add
value(s)to setnameFor more information check https://redis.io/commands/sadd
-
save(**kwargs)¶ Tell the Redis server to save its data to disk, blocking until the save is complete
For more information check https://redis.io/commands/save
-
scan(cursor=0, match=None, count=None, _type=None, **kwargs)¶ Incrementally return lists of key names. Also return a cursor indicating the scan position.
matchallows for filtering the keys by patterncountprovides a hint to Redis about the number of keys to- return per batch.
_typefilters the returned values by a particular Redis type.- Stock Redis instances allow for the following types: HASH, LIST, SET, STREAM, STRING, ZSET Additionally, Redis modules can expose other types as well.
For more information check https://redis.io/commands/scan
-
scan_iter(match=None, count=None, _type=None, **kwargs)¶ Make an iterator using the SCAN command so that the client doesn’t need to remember the cursor position.
matchallows for filtering the keys by patterncountprovides a hint to Redis about the number of keys to- return per batch.
_typefilters the returned values by a particular Redis type.- Stock Redis instances allow for the following types: HASH, LIST, SET, STREAM, STRING, ZSET Additionally, Redis modules can expose other types as well.
-
scard(name)¶ Return the number of elements in set
nameFor more information check https://redis.io/commands/scard
-
script_exists(*args)¶ Check if a script exists in the script cache by specifying the SHAs of each script as
args. Returns a list of boolean values indicating if if each already script exists in the cache.For more information check https://redis.io/commands/script-exists
-
script_flush(sync_type=None)¶ Flush all scripts from the script cache.
sync_typeis by default SYNC (synchronous) but it can also beASYNC.For more information check https://redis.io/commands/script-flush
-
script_kill()¶ Kill the currently executing Lua script
For more information check https://redis.io/commands/script-kill
-
script_load(script)¶ Load a Lua
scriptinto the script cache. Returns the SHA.For more information check https://redis.io/commands/script-load
-
sdiff(keys, *args)¶ Return the difference of sets specified by
keysFor more information check https://redis.io/commands/sdiff
-
sdiffstore(dest, keys, *args)¶ Store the difference of sets specified by
keysinto a new set nameddest. Returns the number of keys in the new set.For more information check https://redis.io/commands/sdiffstore
-
select(index, **kwargs)¶ Select the Redis logical database at index.
-
set(name, value, ex=None, px=None, nx=False, xx=False, keepttl=False, get=False, exat=None, pxat=None)¶ Set the value at key
nametovalueexsets an expire flag on keynameforexseconds.pxsets an expire flag on keynameforpxmilliseconds.nxif set to True, set the value at keynametovalueonly- if it does not exist.
xxif set to True, set the value at keynametovalueonly- if it already exists.
keepttlif True, retain the time to live associated with the key.- (Available since Redis 6.0)
getif True, set the value at keynametovalueand return- the old value stored at key, or None if the key did not exist. (Available since Redis 6.2)
exatsets an expire flag on keynameforexseconds,- specified in unix time.
pxatsets an expire flag on keynameforexmilliseconds,- specified in unix time.
For more information check https://redis.io/commands/set
-
setbit(name, offset, value)¶ Flag the
offsetinnameasvalue. Returns a boolean indicating the previous value ofoffset.For more information check https://redis.io/commands/setbit
-
setex(name, time, value)¶ Set the value of key
nametovaluethat expires intimeseconds.timecan be represented by an integer or a Python timedelta object.For more information check https://redis.io/commands/setex
-
setnx(name, value)¶ Set the value of key
nametovalueif key doesn’t existFor more information check https://redis.io/commands/setnx
-
setrange(name, offset, value)¶ Overwrite bytes in the value of
namestarting atoffsetwithvalue. Ifoffsetplus the length ofvalueexceeds the length of the original value, the new value will be larger than before. Ifoffsetexceeds the length of the original value, null bytes will be used to pad between the end of the previous value and the start of what’s being injected.Returns the length of the new string.
For more information check https://redis.io/commands/setrange
-
shutdown(save=False, nosave=False, **kwargs)¶ Shutdown the Redis server. If Redis has persistence configured, data will be flushed before shutdown. If the “save” option is set, a data flush will be attempted even if there is no persistence configured. If the “nosave” option is set, no data flush will be attempted. The “save” and “nosave” options cannot both be set.
For more information check https://redis.io/commands/shutdown
-
sinter(keys, *args)¶ Return the intersection of sets specified by
keysFor more information check https://redis.io/commands/sinter
-
sinterstore(dest, keys, *args)¶ Store the intersection of sets specified by
keysinto a new set nameddest. Returns the number of keys in the new set.For more information check https://redis.io/commands/sinterstore
-
sismember(name, value)¶ Return a boolean indicating if
valueis a member of setnameFor more information check https://redis.io/commands/sismember
-
slaveof(host=None, port=None, **kwargs)¶ Set the server to be a replicated slave of the instance identified by the
hostandport. If called without arguments, the instance is promoted to a master instead.For more information check https://redis.io/commands/slaveof
-
slowlog_get(num=None, **kwargs)¶ Get the entries from the slowlog. If
numis specified, get the most recentnumitems.For more information check https://redis.io/commands/slowlog-get
-
slowlog_len(**kwargs)¶ Get the number of items in the slowlog
For more information check https://redis.io/commands/slowlog-len
-
slowlog_reset(**kwargs)¶ Remove all items in the slowlog
For more information check https://redis.io/commands/slowlog-reset
-
smembers(name)¶ Return all members of the set
nameFor more information check https://redis.io/commands/smembers
-
smismember(name, values, *args)¶ Return whether each value in
valuesis a member of the setnameas a list ofboolin the order ofvaluesFor more information check https://redis.io/commands/smismember
-
smove(src, dst, value)¶ Move
valuefrom setsrcto setdstatomicallyFor more information check https://redis.io/commands/smove
-
sort(name, start=None, num=None, by=None, get=None, desc=False, alpha=False, store=None, groups=False)¶ Sort and return the list, set or sorted set at
name.startandnumallow for paging through the sorted databyallows using an external key to weight and sort the items.- Use an “*” to indicate where in the key the item value is located
getallows for returning items from external keys rather than the- sorted data itself. Use an “*” to indicate where in the key the item value is located
descallows for reversing the sortalphaallows for sorting lexicographically rather than numericallystoreallows for storing the result of the sort into- the key
store groupsif set to True and ifgetcontains at least two- elements, sort will return a list of tuples, each containing the
values fetched from the arguments to
get.
For more information check https://redis.io/commands/sort
-
spop(name, count=None)¶ Remove and return a random member of set
nameFor more information check https://redis.io/commands/spop
-
srandmember(name, number=None)¶ If
numberis None, returns a random member of setname.If
numberis supplied, returns a list ofnumberrandom members of setname. Note this is only available when running Redis 2.6+.For more information check https://redis.io/commands/srandmember
-
srem(name, *values)¶ Remove
valuesfrom setnameFor more information check https://redis.io/commands/srem
-
sscan(name, cursor=0, match=None, count=None)¶ Incrementally return lists of elements in a set. Also return a cursor indicating the scan position.
matchallows for filtering the keys by patterncountallows for hint the minimum number of returnsFor more information check https://redis.io/commands/sscan
-
sscan_iter(name, match=None, count=None)¶ Make an iterator using the SSCAN command so that the client doesn’t need to remember the cursor position.
matchallows for filtering the keys by patterncountallows for hint the minimum number of returns
-
stralgo(algo, value1, value2, specific_argument='strings', len=False, idx=False, minmatchlen=None, withmatchlen=False, **kwargs)¶ Implements complex algorithms that operate on strings. Right now the only algorithm implemented is the LCS algorithm (longest common substring). However new algorithms could be implemented in the future.
algoRight now must be LCSvalue1andvalue2Can be two strings or two keysspecific_argumentSpecifying if the arguments to the algorithm will be keys or strings. strings is the default.lenReturns just the len of the match.idxReturns the match positions in each string.minmatchlenRestrict the list of matches to the ones of a given minimal length. Can be provided only whenidxset to True.withmatchlenReturns the matches with the len of the match. Can be provided only whenidxset to True.For more information check https://redis.io/commands/stralgo
-
strlen(name)¶ Return the number of bytes stored in the value of
nameFor more information check https://redis.io/commands/strlen
-
substr(name, start, end=-1)¶ Return a substring of the string at key
name.startandendare 0-based integers specifying the portion of the string to return.
-
sunion(keys, *args)¶ Return the union of sets specified by
keysFor more information check https://redis.io/commands/sunion
-
sunionstore(dest, keys, *args)¶ Store the union of sets specified by
keysinto a new set nameddest. Returns the number of keys in the new set.For more information check https://redis.io/commands/sunionstore
-
swapdb(first, second, **kwargs)¶ Swap two databases
For more information check https://redis.io/commands/swapdb
-
sync()¶ Initiates a replication stream from the master.
For more information check https://redis.io/commands/sync
-
time(**kwargs)¶ Returns the server time as a 2-item tuple of ints: (seconds since epoch, microseconds into this second).
For more information check https://redis.io/commands/time
-
touch(*args)¶ Alters the last access time of a key(s)
*args. A key is ignored if it does not exist.For more information check https://redis.io/commands/touch
-
ttl(name)¶ Returns the number of seconds until the key
namewill expireFor more information check https://redis.io/commands/ttl
-
type(name)¶ Returns the type of key
nameFor more information check https://redis.io/commands/type
-
unlink(*names)¶ Unlink one or more keys specified by
namesFor more information check https://redis.io/commands/unlink
-
unwatch()¶ Unwatches the value at key
name, or None of the key doesn’t existFor more information check https://redis.io/commands/unwatch
-
wait(num_replicas, timeout, **kwargs)¶ Redis synchronous replication That returns the number of replicas that processed the query when we finally have at least
num_replicas, or when thetimeoutwas reached.For more information check https://redis.io/commands/wait
-
watch(*names)¶ Watches the values at keys
names, or None if the key doesn’t existFor more information check https://redis.io/commands/type
-
xack(name, groupname, *ids)¶ Acknowledges the successful processing of one or more messages. name: name of the stream. groupname: name of the consumer group. *ids: message ids to acknowledge.
For more information check https://redis.io/commands/xack
-
xadd(name, fields, id='*', maxlen=None, approximate=True, nomkstream=False, minid=None, limit=None)¶ Add to a stream. name: name of the stream fields: dict of field/value pairs to insert into the stream id: Location to insert this record. By default it is appended. maxlen: truncate old stream members beyond this size. Can’t be specified with minid. approximate: actual stream length may be slightly more than maxlen nomkstream: When set to true, do not make a stream minid: the minimum id in the stream to query. Can’t be specified with maxlen. limit: specifies the maximum number of entries to retrieve
For more information check https://redis.io/commands/xadd
-
xautoclaim(name, groupname, consumername, min_idle_time, start_id=0, count=None, justid=False)¶ Transfers ownership of pending stream entries that match the specified criteria. Conceptually, equivalent to calling XPENDING and then XCLAIM, but provides a more straightforward way to deal with message delivery failures via SCAN-like semantics. name: name of the stream. groupname: name of the consumer group. consumername: name of a consumer that claims the message. min_idle_time: filter messages that were idle less than this amount of milliseconds. start_id: filter messages with equal or greater ID. count: optional integer, upper limit of the number of entries that the command attempts to claim. Set to 100 by default. justid: optional boolean, false by default. Return just an array of IDs of messages successfully claimed, without returning the actual message
For more information check https://redis.io/commands/xautoclaim
-
xclaim(name, groupname, consumername, min_idle_time, message_ids, idle=None, time=None, retrycount=None, force=False, justid=False)¶ Changes the ownership of a pending message. name: name of the stream. groupname: name of the consumer group. consumername: name of a consumer that claims the message. min_idle_time: filter messages that were idle less than this amount of milliseconds message_ids: non-empty list or tuple of message IDs to claim idle: optional. Set the idle time (last time it was delivered) of the
message in ms- time: optional integer. This is the same as idle but instead of a
- relative amount of milliseconds, it sets the idle time to a specific Unix time (in milliseconds).
- retrycount: optional integer. set the retry counter to the specified
- value. This counter is incremented every time a message is delivered again.
- force: optional boolean, false by default. Creates the pending message
- entry in the PEL even if certain specified IDs are not already in the PEL assigned to a different client.
- justid: optional boolean, false by default. Return just an array of IDs
of messages successfully claimed, without returning the actual message
For more information check https://redis.io/commands/xclaim
-
xdel(name, *ids)¶ Deletes one or more messages from a stream. name: name of the stream. *ids: message ids to delete.
For more information check https://redis.io/commands/xdel
-
xgroup_create(name, groupname, id='$', mkstream=False)¶ Create a new consumer group associated with a stream. name: name of the stream. groupname: name of the consumer group. id: ID of the last item in the stream to consider already delivered.
For more information check https://redis.io/commands/xgroup-create
-
xgroup_createconsumer(name, groupname, consumername)¶ Consumers in a consumer group are auto-created every time a new consumer name is mentioned by some command. They can be explicitly created by using this command. name: name of the stream. groupname: name of the consumer group. consumername: name of consumer to create.
-
xgroup_delconsumer(name, groupname, consumername)¶ Remove a specific consumer from a consumer group. Returns the number of pending messages that the consumer had before it was deleted. name: name of the stream. groupname: name of the consumer group. consumername: name of consumer to delete
For more information check https://redis.io/commands/xgroup-delconsumer
-
xgroup_destroy(name, groupname)¶ Destroy a consumer group. name: name of the stream. groupname: name of the consumer group.
For more information check https://redis.io/commands/xgroup-destroy
-
xgroup_setid(name, groupname, id)¶ Set the consumer group last delivered ID to something else. name: name of the stream. groupname: name of the consumer group. id: ID of the last item in the stream to consider already delivered.
For more information check https://redis.io/commands/xgroup-setid
-
xinfo_consumers(name, groupname)¶ Returns general information about the consumers in the group. name: name of the stream. groupname: name of the consumer group.
For more information check https://redis.io/commands/xinfo-consumers
-
xinfo_groups(name)¶ Returns general information about the consumer groups of the stream. name: name of the stream.
For more information check https://redis.io/commands/xinfo-groups
-
xinfo_stream(name, full=False)¶ Returns general information about the stream. name: name of the stream. full: optional boolean, false by default. Return full summary
For more information check https://redis.io/commands/xinfo-stream
-
xlen(name)¶ Returns the number of elements in a given stream.
For more information check https://redis.io/commands/xlen
-
xpending(name, groupname)¶ Returns information about pending messages of a group. name: name of the stream. groupname: name of the consumer group.
For more information check https://redis.io/commands/xpending
-
xpending_range(name, groupname, idle=None, min=None, max=None, count=None, consumername=None)¶ Returns information about pending messages, in a range.
name: name of the stream. groupname: name of the consumer group. idle: available from version 6.2. filter entries by their idle-time, given in milliseconds (optional). min: minimum stream ID. max: maximum stream ID. count: number of messages to return consumername: name of a consumer to filter by (optional).
-
xrange(name, min='-', max='+', count=None)¶ Read stream values within an interval. name: name of the stream. start: first stream ID. defaults to ‘-‘,
meaning the earliest available.- finish: last stream ID. defaults to ‘+’,
- meaning the latest available.
- count: if set, only return this many items, beginning with the
- earliest available.
For more information check https://redis.io/commands/xrange
-
xread(streams, count=None, block=None)¶ Block and monitor multiple streams for new data. streams: a dict of stream names to stream IDs, where
IDs indicate the last ID already seen.- count: if set, only return this many items, beginning with the
- earliest available.
block: number of milliseconds to wait, if nothing already present.
For more information check https://redis.io/commands/xread
-
xreadgroup(groupname, consumername, streams, count=None, block=None, noack=False)¶ Read from a stream via a consumer group. groupname: name of the consumer group. consumername: name of the requesting consumer. streams: a dict of stream names to stream IDs, where
IDs indicate the last ID already seen.- count: if set, only return this many items, beginning with the
- earliest available.
block: number of milliseconds to wait, if nothing already present. noack: do not add messages to the PEL
For more information check https://redis.io/commands/xreadgroup
-
xrevrange(name, max='+', min='-', count=None)¶ Read stream values within an interval, in reverse order. name: name of the stream start: first stream ID. defaults to ‘+’,
meaning the latest available.- finish: last stream ID. defaults to ‘-‘,
- meaning the earliest available.
- count: if set, only return this many items, beginning with the
- latest available.
For more information check https://redis.io/commands/xrevrange
-
xtrim(name, maxlen=None, approximate=True, minid=None, limit=None)¶ Trims old messages from a stream. name: name of the stream. maxlen: truncate old stream messages beyond this size Can’t be specified with minid. approximate: actual stream length may be slightly more than maxlen minid: the minimum id in the stream to query Can’t be specified with maxlen. limit: specifies the maximum number of entries to retrieve
For more information check https://redis.io/commands/xtrim
-
zadd(name, mapping, nx=False, xx=False, ch=False, incr=False, gt=None, lt=None)¶ Set any number of element-name, score pairs to the key
name. Pairs are specified as a dict of element-names keys to score values.nxforces ZADD to only create new elements and not to update scores for elements that already exist.xxforces ZADD to only update scores of elements that already exist. New elements will not be added.chmodifies the return value to be the numbers of elements changed. Changed elements include new elements that were added and elements whose scores changed.incrmodifies ZADD to behave like ZINCRBY. In this mode only a single element/score pair can be specified and the score is the amount the existing score will be incremented by. When using this mode the return value of ZADD will be the new score of the element.LTOnly update existing elements if the new score is less than the current score. This flag doesn’t prevent adding new elements.GTOnly update existing elements if the new score is greater than the current score. This flag doesn’t prevent adding new elements.The return value of ZADD varies based on the mode specified. With no options, ZADD returns the number of new elements added to the sorted set.
NX,LT, andGTare mutually exclusive options.
-
zcard(name)¶ Return the number of elements in the sorted set
nameFor more information check https://redis.io/commands/zcard
-
zcount(name, min, max)¶ Returns the number of elements in the sorted set at key
namewith a score betweenminandmax.For more information check https://redis.io/commands/zcount
-
zdiff(keys, withscores=False)¶ Returns the difference between the first and all successive input sorted sets provided in
keys.For more information check https://redis.io/commands/zdiff
-
zdiffstore(dest, keys)¶ Computes the difference between the first and all successive input sorted sets provided in
keysand stores the result indest.For more information check https://redis.io/commands/zdiffstore
-
zincrby(name, amount, value)¶ Increment the score of
valuein sorted setnamebyamountFor more information check https://redis.io/commands/zincrby
-
zinter(keys, aggregate=None, withscores=False)¶ Return the intersect of multiple sorted sets specified by
keys. With theaggregateoption, it is possible to specify how the results of the union are aggregated. This option defaults to SUM, where the score of an element is summed across the inputs where it exists. When this option is set to either MIN or MAX, the resulting set will contain the minimum or maximum score of an element across the inputs where it exists.For more information check https://redis.io/commands/zinter
-
zinterstore(dest, keys, aggregate=None)¶ Intersect multiple sorted sets specified by
keysinto a new sorted set,dest. Scores in the destination will be aggregated based on theaggregate. This option defaults to SUM, where the score of an element is summed across the inputs where it exists. When this option is set to either MIN or MAX, the resulting set will contain the minimum or maximum score of an element across the inputs where it exists.For more information check https://redis.io/commands/zinterstore
-
zlexcount(name, min, max)¶ Return the number of items in the sorted set
namebetween the lexicographical rangeminandmax.For more information check https://redis.io/commands/zlexcount
-
zmscore(key, members)¶ Returns the scores associated with the specified members in the sorted set stored at key.
membersshould be a list of the member name. Return type is a list of score. If the member does not exist, a None will be returned in corresponding position.For more information check https://redis.io/commands/zmscore
-
zpopmax(name, count=None)¶ Remove and return up to
countmembers with the highest scores from the sorted setname.For more information check https://redis.io/commands/zpopmax
-
zpopmin(name, count=None)¶ Remove and return up to
countmembers with the lowest scores from the sorted setname.For more information check https://redis.io/commands/zpopmin
-
zrandmember(key, count=None, withscores=False)¶ Return a random element from the sorted set value stored at key.
countif the argument is positive, return an array of distinct fields. If called with a negative count, the behavior changes and the command is allowed to return the same field multiple times. In this case, the number of returned fields is the absolute value of the specified count.withscoresThe optional WITHSCORES modifier changes the reply so it includes the respective scores of the randomly selected elements from the sorted set.For more information check https://redis.io/commands/zrandmember
-
zrange(name, start, end, desc=False, withscores=False, score_cast_func=<class 'float'>, byscore=False, bylex=False, offset=None, num=None)¶ Return a range of values from sorted set
namebetweenstartandendsorted in ascending order.startandendcan be negative, indicating the end of the range.desca boolean indicating whether to sort the results in reversed order.withscoresindicates to return the scores along with the values. The return type is a list of (value, score) pairs.score_cast_funca callable used to cast the score return value.byscorewhen set to True, returns the range of elements from the sorted set having scores equal or betweenstartandend.bylexwhen set to True, returns the range of elements from the sorted set between thestartandendlexicographical closed range intervals. Validstartandendmust start with ( or [, in order to specify whether the range interval is exclusive or inclusive, respectively.offsetandnumare specified, then return a slice of the range. Can’t be provided when usingbylex.For more information check https://redis.io/commands/zrange
-
zrangebylex(name, min, max, start=None, num=None)¶ Return the lexicographical range of values from sorted set
namebetweenminandmax.If
startandnumare specified, then return a slice of the range.For more information check https://redis.io/commands/zrangebylex
-
zrangebyscore(name, min, max, start=None, num=None, withscores=False, score_cast_func=<class 'float'>)¶ Return a range of values from the sorted set
namewith scores betweenminandmax.If
startandnumare specified, then return a slice of the range.withscoresindicates to return the scores along with the values. The return type is a list of (value, score) pairsscore_cast_func` a callable used to cast the score return value
For more information check https://redis.io/commands/zrangebyscore
-
zrangestore(dest, name, start, end, byscore=False, bylex=False, desc=False, offset=None, num=None)¶ Stores in
destthe result of a range of values from sorted setnamebetweenstartandendsorted in ascending order.startandendcan be negative, indicating the end of the range.byscorewhen set to True, returns the range of elements from the sorted set having scores equal or betweenstartandend.bylexwhen set to True, returns the range of elements from the sorted set between thestartandendlexicographical closed range intervals. Validstartandendmust start with ( or [, in order to specify whether the range interval is exclusive or inclusive, respectively.desca boolean indicating whether to sort the results in reversed order.offsetandnumare specified, then return a slice of the range. Can’t be provided when usingbylex.For more information check https://redis.io/commands/zrangestore
-
zrank(name, value)¶ Returns a 0-based value indicating the rank of
valuein sorted setnameFor more information check https://redis.io/commands/zrank
-
zrem(name, *values)¶ Remove member
valuesfrom sorted setnameFor more information check https://redis.io/commands/zrem
-
zremrangebylex(name, min, max)¶ Remove all elements in the sorted set
namebetween the lexicographical range specified byminandmax.Returns the number of elements removed.
For more information check https://redis.io/commands/zremrangebylex
-
zremrangebyrank(name, min, max)¶ Remove all elements in the sorted set
namewith ranks betweenminandmax. Values are 0-based, ordered from smallest score to largest. Values can be negative indicating the highest scores. Returns the number of elements removedFor more information check https://redis.io/commands/zremrangebyrank
-
zremrangebyscore(name, min, max)¶ Remove all elements in the sorted set
namewith scores betweenminandmax. Returns the number of elements removed.For more information check https://redis.io/commands/zremrangebyscore
-
zrevrange(name, start, end, withscores=False, score_cast_func=<class 'float'>)¶ Return a range of values from sorted set
namebetweenstartandendsorted in descending order.startandendcan be negative, indicating the end of the range.withscoresindicates to return the scores along with the values The return type is a list of (value, score) pairsscore_cast_funca callable used to cast the score return valueFor more information check https://redis.io/commands/zrevrange
-
zrevrangebylex(name, max, min, start=None, num=None)¶ Return the reversed lexicographical range of values from sorted set
namebetweenmaxandmin.If
startandnumare specified, then return a slice of the range.For more information check https://redis.io/commands/zrevrangebylex
-
zrevrangebyscore(name, max, min, start=None, num=None, withscores=False, score_cast_func=<class 'float'>)¶ Return a range of values from the sorted set
namewith scores betweenminandmaxin descending order.If
startandnumare specified, then return a slice of the range.withscoresindicates to return the scores along with the values. The return type is a list of (value, score) pairsscore_cast_funca callable used to cast the score return valueFor more information check https://redis.io/commands/zrevrangebyscore
-
zrevrank(name, value)¶ Returns a 0-based value indicating the descending rank of
valuein sorted setnameFor more information check https://redis.io/commands/zrevrank
-
zscan(name, cursor=0, match=None, count=None, score_cast_func=<class 'float'>)¶ Incrementally return lists of elements in a sorted set. Also return a cursor indicating the scan position.
matchallows for filtering the keys by patterncountallows for hint the minimum number of returnsscore_cast_funca callable used to cast the score return valueFor more information check https://redis.io/commands/zscan
-
zscan_iter(name, match=None, count=None, score_cast_func=<class 'float'>)¶ Make an iterator using the ZSCAN command so that the client doesn’t need to remember the cursor position.
matchallows for filtering the keys by patterncountallows for hint the minimum number of returnsscore_cast_funca callable used to cast the score return value
-
zscore(name, value)¶ Return the score of element
valuein sorted setnameFor more information check https://redis.io/commands/zscore
-
zunion(keys, aggregate=None, withscores=False)¶ Return the union of multiple sorted sets specified by
keys.keyscan be provided as dictionary of keys and their weights. Scores will be aggregated based on theaggregate, or SUM if none is provided.For more information check https://redis.io/commands/zunion
-
zunionstore(dest, keys, aggregate=None)¶ Union multiple sorted sets specified by
keysinto a new sorted set,dest. Scores in the destination will be aggregated based on theaggregate, or SUM if none is provided.For more information check https://redis.io/commands/zunionstore
-