KVDBSession
Sessions are the underlying object that contains the state of a single KVDB
connection to a server. This session contains both asynchronous and synchronous methods for interacting with the server, as well as methods for managing the session itself.
The underlying connection pools are managed by the KVDBClient
class, which is a singleton that manages all sessions. This allows you to create multiple sessions with different configurations, but still share the same underlying connection pool, unless there is any configuration differences that would require a new connection pool.
API Reference
Bases: abc.ABC
The KVDB Session protocol
Initializes the KVDB Session
Source code in kvdb/components/session.py
persistence
property
Returns the PersistentDict
instance
that utilizes the session's client
session_serialization_enabled
property
Returns whether session serialization is enabled which is determined by the pool's encoder serialization to be enabled
__aenter__
async
__aexit__
async
__contains__
__delitem__
__enter__
__exit__
__exit__(
exc_type: (
kvdb.components.session.KVDBSession.type[
BaseException
]
| None
),
exc_val: BaseException | None,
exc_tb: types.TracebackType | None,
)
__getitem__
__setitem__
[Dict] Sets the value for the given key
Source code in kvdb/components/session.py
aacl_cat
async
Returns a list of categories or commands within a category.
If category
is not supplied, returns a list of all categories.
If category
is supplied, returns a list of all commands within
that category.
For more information see https://redis.io/commands/acl-cat
Source code in kvdb/components/session.py
aacl_deluser
async
Delete the ACL for the specified username
s
For more information see https://redis.io/commands/acl-deluser
aacl_dryrun
async
Simulate the execution of a given command by a given username
.
For more information see https://redis.io/commands/acl-dryrun
aacl_genpass
async
Generate a random password value.
If bits
is supplied then use this number of bits, rounded to
the next multiple of 4.
See: https://redis.io/commands/acl-genpass
aacl_getuser
async
Get the ACL details for the specified username
.
If username
does not exist, return None
For more information see https://redis.io/commands/acl-getuser
aacl_help
async
The ACL HELP command returns helpful text describing the different subcommands.
For more information see https://redis.io/commands/acl-help
aacl_list
async
Return a list of all ACLs on the server
For more information see https://redis.io/commands/acl-list
Source code in kvdb/components/session.py
aacl_load
async
Load ACL rules from the configured aclfile
.
Note that the server must be configured with the aclfile
directive to be able to load ACL rules from an aclfile.
For more information see https://redis.io/commands/acl-load
Source code in kvdb/components/session.py
aacl_log
async
Get ACL logs as a list. :param int count: Get logs[0:count]. :rtype: List.
For more information see https://redis.io/commands/acl-log
Source code in kvdb/components/session.py
aacl_log_reset
async
aacl_save
async
Save ACL rules to the configured aclfile
.
Note that the server must be configured with the aclfile
directive to be able to save ACL rules to an aclfile.
For more information see https://redis.io/commands/acl-save
Source code in kvdb/components/session.py
aacl_setuser
async
aacl_setuser(
username: str,
enabled: bool = False,
nopass: bool = False,
passwords: typing.Union[
str, typing.Iterable[str], None
] = None,
hashed_passwords: typing.Union[
str, typing.Iterable[str], None
] = None,
categories: typing.Optional[
typing.Iterable[str]
] = None,
commands: typing.Optional[typing.Iterable[str]] = None,
keys: typing.Optional[
typing.Iterable[kvdb.types.generic.KeyT]
] = None,
channels: typing.Optional[
typing.Iterable[redis.typing.ChannelT]
] = None,
selectors: typing.Optional[
typing.Iterable[
typing.Tuple[str, kvdb.types.generic.KeyT]
]
] = None,
reset: bool = False,
reset_keys: bool = False,
reset_channels: bool = False,
reset_passwords: bool = False,
**kwargs
) -> redis.commands.core.ResponseT
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.
enabled
is a boolean indicating whether the user should be allowed
to authenticate or not. Defaults to False
.
nopass
is a boolean indicating whether the can authenticate without
a password. This cannot be True if passwords
are also specified.
passwords
if 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 of
passwords
can be a simple prefixed string when adding or
removing a single password.
hashed_passwords
if 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 of hashed_passwords
can be a simple prefixed string when
adding or removing a single password.
categories
if 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.
commands
if 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.
keys
if 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:'. keys
should not be
prefixed with a '~'.
reset
is 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_keys
is a boolean indicating whether the user's key
permissions should be reset prior to applying any new key permissions
specified in keys
. 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_channels
is a boolean indicating whether the user's channel
permissions should be reset prior to applying any new channel permissions
specified in channels
.If this is False, the user's existing
channel permissions will be kept and any new specified channel permissions
will be applied on top.
reset_passwords
is 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 see https://redis.io/commands/acl-setuser
Source code in kvdb/components/session.py
aacl_users
async
Returns a list of all registered users on the server.
For more information see https://redis.io/commands/acl-users
Source code in kvdb/components/session.py
aacl_whoami
async
Get the username for the current connection
For more information see https://redis.io/commands/acl-whoami
aappend
async
aappend(
key: kvdb.types.generic.KeyT,
value: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Appends the string value
to the value at key
. If key
doesn't already exist, create it with a value of value
.
Returns the new length of the value at key
.
For more information see https://redis.io/commands/append
aauth
async
Authenticates the user. If you do not pass username, Redis will try to authenticate for the "default" user. If you do pass username, it will authenticate for the given user. For more information see https://redis.io/commands/auth
abgrewriteaof
async
abgsave
async
Tell the Redis server to save its data to disk. Unlike save(), this method is asynchronous and returns immediately.
For more information see https://redis.io/commands/bgsave
abitcount
async
abitcount(
key: kvdb.types.generic.KeyT,
start: typing.Union[int, None] = None,
end: typing.Union[int, None] = None,
mode: typing.Optional[str] = None,
) -> redis.commands.core.ResponseT
Returns the count of set bits in the value of key
. Optional
start
and end
parameters indicate which bytes to consider
For more information see https://redis.io/commands/bitcount
abitfield
async
abitfield(
key: kvdb.types.generic.KeyT,
default_overflow: typing.Union[str, None] = None,
) -> redis.commands.core.BitFieldOperation
Return a BitFieldOperation instance to conveniently construct one or
more bitfield operations on key
.
For more information see https://redis.io/commands/bitfield
abitfield_ro
async
abitfield_ro(
key: kvdb.types.generic.KeyT,
encoding: str,
offset: redis.typing.BitfieldOffsetT,
items: typing.Optional[list] = None,
) -> redis.commands.core.ResponseT
Return an array of the specified bitfield values
where the first value is found using encoding
and offset
parameters and remaining values are result of corresponding
encoding/offset pairs in optional list items
Read-only variant of the BITFIELD command.
For more information see https://redis.io/commands/bitfield_ro
abitop
async
abitop(
operation: str,
dest: kvdb.types.generic.KeyT,
*keys: kvdb.types.generic.KeyT
) -> redis.commands.core.ResponseT
Perform a bitwise operation using operation
between keys
and
store the result in dest
.
For more information see https://redis.io/commands/bitop
abitpos
async
abitpos(
key: kvdb.types.generic.KeyT,
bit: int,
start: typing.Union[int, None] = None,
end: typing.Union[int, None] = None,
mode: typing.Optional[str] = None,
) -> redis.commands.core.ResponseT
Return the position of the first bit set to 1 or 0 in a string.
start
and end
defines 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 see https://redis.io/commands/bitpos
ablmove
async
ablmove(
first_list: str,
second_list: str,
timeout: int,
src: str = "LEFT",
dest: str = "RIGHT",
) -> redis.commands.core.ResponseT
Blocking version of lmove.
For more information see https://redis.io/commands/blmove
ablmpop
async
ablmpop(
timeout: float,
numkeys: int,
*args: typing.List[str],
direction: str,
count: typing.Optional[int] = 1
) -> typing.Optional[list]
Pop count
values (default 1) from first non-empty in the list
of provided key names.
When all lists are empty this command blocks the connection until another client pushes to it or until the timeout, timeout of 0 blocks indefinitely
For more information see https://redis.io/commands/blmpop
ablpop
async
ablpop(
keys: typing.List, timeout: typing.Optional[int] = 0
) -> typing.Union[typing.Awaitable[list], list]
LPOP a value off of the first non-empty list
named in the keys
list.
If none of the lists in keys
has a value to LPOP, then block
for timeout
seconds, or until a value gets pushed on to one
of the lists.
If timeout is 0, then block indefinitely.
For more information see https://redis.io/commands/blpop
abrpop
async
abrpop(
keys: typing.List, timeout: typing.Optional[int] = 0
) -> typing.Union[typing.Awaitable[list], list]
RPOP a value off of the first non-empty list
named in the keys
list.
If none of the lists in keys
has a value to RPOP, then block
for timeout
seconds, or until a value gets pushed on to one
of the lists.
If timeout is 0, then block indefinitely.
For more information see https://redis.io/commands/brpop
abrpoplpush
async
abrpoplpush(
src: str, dst: str, timeout: typing.Optional[int] = 0
) -> typing.Union[
typing.Awaitable[typing.Optional[str]],
typing.Optional[str],
]
Pop a value off the tail of src
, push it on the head of dst
and then return it.
This command blocks until a value is in src
or until timeout
seconds elapse, whichever is first. A timeout
value of 0 blocks
forever.
For more information see https://redis.io/commands/brpoplpush
abzmpop
async
abzmpop(
timeout: float,
numkeys: int,
keys: typing.List[str],
min: typing.Optional[bool] = False,
max: typing.Optional[bool] = False,
count: typing.Optional[int] = 1,
) -> typing.Optional[list]
Pop count
values (default 1) off of the first non-empty sorted set
named in the keys
list.
If none of the sorted sets in keys
has a value to pop,
then block for timeout
seconds, or until a member gets added
to one of the sorted sets.
If timeout is 0, then block indefinitely.
For more information see https://redis.io/commands/bzmpop
abzpopmax
async
abzpopmax(
keys: redis.typing.KeysT,
timeout: redis.typing.TimeoutSecT = 0,
) -> redis.commands.core.ResponseT
ZPOPMAX a value off of the first non-empty sorted set
named in the keys
list.
If none of the sorted sets in keys
has a value to ZPOPMAX,
then block for timeout
seconds, or until a member gets added
to one of the sorted sets.
If timeout is 0, then block indefinitely.
For more information see https://redis.io/commands/bzpopmax
abzpopmin
async
abzpopmin(
keys: redis.typing.KeysT,
timeout: redis.typing.TimeoutSecT = 0,
) -> redis.commands.core.ResponseT
ZPOPMIN a value off of the first non-empty sorted set
named in the keys
list.
If none of the sorted sets in keys
has a value to ZPOPMIN,
then block for timeout
seconds, or until a member gets added
to one of the sorted sets.
If timeout is 0, then block indefinitely.
For more information see https://redis.io/commands/bzpopmin
acl_cat
Returns a list of categories or commands within a category.
If category
is not supplied, returns a list of all categories.
If category
is supplied, returns a list of all commands within
that category.
For more information see https://redis.io/commands/acl-cat
acl_deluser
Delete the ACL for the specified username
s
For more information see https://redis.io/commands/acl-deluser
acl_dryrun
Simulate the execution of a given command by a given username
.
For more information see https://redis.io/commands/acl-dryrun
acl_genpass
Generate a random password value.
If bits
is supplied then use this number of bits, rounded to
the next multiple of 4.
See: https://redis.io/commands/acl-genpass
acl_getuser
Get the ACL details for the specified username
.
If username
does not exist, return None
For more information see https://redis.io/commands/acl-getuser
acl_help
The ACL HELP command returns helpful text describing the different subcommands.
For more information see https://redis.io/commands/acl-help
acl_list
Return a list of all ACLs on the server
For more information see https://redis.io/commands/acl-list
acl_load
Load ACL rules from the configured aclfile
.
Note that the server must be configured with the aclfile
directive to be able to load ACL rules from an aclfile.
For more information see https://redis.io/commands/acl-load
acl_log
Get ACL logs as a list. :param int count: Get logs[0:count]. :rtype: List.
For more information see https://redis.io/commands/acl-log
acl_log_reset
Reset ACL logs. :rtype: Boolean.
For more information see https://redis.io/commands/acl-log
acl_save
Save ACL rules to the configured aclfile
.
Note that the server must be configured with the aclfile
directive to be able to save ACL rules to an aclfile.
For more information see https://redis.io/commands/acl-save
acl_setuser
acl_setuser(
username: str,
enabled: bool = False,
nopass: bool = False,
passwords: typing.Union[
str, typing.Iterable[str], None
] = None,
hashed_passwords: typing.Union[
str, typing.Iterable[str], None
] = None,
categories: typing.Optional[
typing.Iterable[str]
] = None,
commands: typing.Optional[typing.Iterable[str]] = None,
keys: typing.Optional[
typing.Iterable[kvdb.types.generic.KeyT]
] = None,
channels: typing.Optional[
typing.Iterable[redis.typing.ChannelT]
] = None,
selectors: typing.Optional[
typing.Iterable[
typing.Tuple[str, kvdb.types.generic.KeyT]
]
] = None,
reset: bool = False,
reset_keys: bool = False,
reset_channels: bool = False,
reset_passwords: bool = False,
**kwargs
) -> redis.commands.core.ResponseT
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.
enabled
is a boolean indicating whether the user should be allowed
to authenticate or not. Defaults to False
.
nopass
is a boolean indicating whether the can authenticate without
a password. This cannot be True if passwords
are also specified.
passwords
if 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 of
passwords
can be a simple prefixed string when adding or
removing a single password.
hashed_passwords
if 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 of hashed_passwords
can be a simple prefixed string when
adding or removing a single password.
categories
if 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.
commands
if 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.
keys
if 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:'. keys
should not be
prefixed with a '~'.
reset
is 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_keys
is a boolean indicating whether the user's key
permissions should be reset prior to applying any new key permissions
specified in keys
. 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_channels
is a boolean indicating whether the user's channel
permissions should be reset prior to applying any new channel permissions
specified in channels
.If this is False, the user's existing
channel permissions will be kept and any new specified channel permissions
will be applied on top.
reset_passwords
is 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 see https://redis.io/commands/acl-setuser
acl_users
Returns a list of all registered users on the server.
For more information see https://redis.io/commands/acl-users
acl_whoami
Get the username for the current connection
For more information see https://redis.io/commands/acl-whoami
aclient_getname
async
aclient_getredir
async
Returns the ID (an integer) of the client to whom we are redirecting tracking notifications.
see: https://redis.io/commands/client-getredir
aclient_id
async
Returns the current connection id
For more information see https://redis.io/commands/client-id
aclient_info
async
Returns information and statistics about the current client connection.
For more information see https://redis.io/commands/client-info
aclient_kill
async
Disconnects the client at address
(ip:port)
For more information see https://redis.io/commands/client-kill
aclient_kill_filter
async
aclient_kill_filter(
_id: typing.Union[str, None] = None,
_type: typing.Union[str, None] = None,
addr: typing.Union[str, None] = None,
skipme: typing.Union[bool, None] = None,
laddr: typing.Union[bool, None] = None,
user: str = None,
**kwargs
) -> redis.commands.core.ResponseT
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
Source code in kvdb/components/session.py
aclient_list
async
aclient_list(
_type: typing.Union[str, None] = None,
client_id: typing.List[redis.typing.EncodableT] = [],
**kwargs
) -> redis.commands.core.ResponseT
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) :param client_id: optional. a list of client ids
For more information see https://redis.io/commands/client-list
Source code in kvdb/components/session.py
aclient_no_evict
async
aclient_no_touch
async
The command controls whether commands sent by the client will alter
the LRU/LFU of the keys they access.
When turned on, the current client will not change LFU/LRU stats,
unless it sends the TOUCH command.
For more information see https://redis.io/commands/client-no-touch
Source code in kvdb/components/session.py
aclient_pause
async
Suspend all the Redis clients for the specified amount of time.
For more information see https://redis.io/commands/client-pause
:param timeout: milliseconds to pause clients :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.
Source code in kvdb/components/session.py
aclient_reply
async
aclient_reply(
reply: typing.Union[
typing.Literal["ON"],
typing.Literal["OFF"],
typing.Literal["SKIP"],
],
**kwargs
) -> redis.commands.core.ResponseT
Enable and disable redis server replies.
reply
Must 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.
See https://redis.io/commands/client-reply
Source code in kvdb/components/session.py
aclient_setinfo
async
aclient_setname
async
Sets the current connection name
For more information see https://redis.io/commands/client-setname
.. note:: This method sets client name only for current connection.
If you want to set a common name for all connections managed
by this client, use client_name
constructor argument.
aclient_tracking
async
aclient_tracking(
on: bool = True,
clientid: typing.Union[int, None] = None,
prefix: typing.Sequence[kvdb.types.generic.KeyT] = [],
bcast: bool = False,
optin: bool = False,
optout: bool = False,
noloop: bool = False,
**kwargs
) -> redis.commands.core.ResponseT
Enables the tracking feature of the Redis server, that is used for server assisted client side caching.
on
indicate for tracking on or tracking off. The dafualt is on.
clientid
send invalidation messages to the connection with
the specified ID.
bcast
enable tracking in broadcasting mode. In this mode
invalidation messages are reported for all the prefixes
specified, regardless of the keys requested by the connection.
optin
when broadcasting is NOT active, normally don't track
keys in read only commands, unless they are called immediately
after a CLIENT CACHING yes command.
optout
when broadcasting is NOT active, normally track keys in
read only commands, unless they are called immediately after a
CLIENT CACHING no command.
noloop
don't send notifications about keys modified by this
connection itself.
prefix
for broadcasting, register a given key prefix, so that
notifications will be provided only for keys starting with this string.
See https://redis.io/commands/client-tracking
Source code in kvdb/components/session.py
aclient_tracking_off
async
aclient_tracking_off(
clientid: typing.Union[int, None] = None,
prefix: typing.Sequence[kvdb.types.generic.KeyT] = [],
bcast: bool = False,
optin: bool = False,
optout: bool = False,
noloop: bool = False,
) -> redis.commands.core.ResponseT
Turn off the tracking mode. For more information about the options look at client_tracking func.
See https://redis.io/commands/client-tracking
aclient_tracking_on
async
aclient_tracking_on(
clientid: typing.Union[int, None] = None,
prefix: typing.Sequence[kvdb.types.generic.KeyT] = [],
bcast: bool = False,
optin: bool = False,
optout: bool = False,
noloop: bool = False,
) -> redis.commands.core.ResponseT
Turn on the tracking mode. For more information about the options look at client_tracking func.
See https://redis.io/commands/client-tracking
aclient_trackinginfo
async
Returns the information about the current client connection's use of the server assisted client side cache.
See https://redis.io/commands/client-trackinginfo
aclient_unblock
async
Unblocks a connection by its client id.
If error
is True, unblocks the client with a special error message.
If error
is False (default), the client is unblocked using the
regular timeout mechanism.
For more information see https://redis.io/commands/client-unblock
aclient_unpause
async
Unpause all redis clients
For more information see https://redis.io/commands/client-unpause
aclose
async
aclose(
close_pool: bool = False,
force: typing.Optional[bool] = None,
raise_errors: bool = False,
)
Close the session
Source code in kvdb/components/session.py
aclose_locks
async
aclose_locks(
names: typing.Optional[
typing.Union[typing.List[str], str]
] = None,
force: typing.Optional[bool] = False,
raise_errors: typing.Optional[bool] = False,
)
Closes the locks that are currently managed by the session
Source code in kvdb/components/session.py
acommand_docs
async
acommand_getkeysandflags
async
acommand_getkeysandflags(
*args: typing.List[str],
) -> typing.List[typing.Union[str, typing.List[str]]]
Returns array of keys from a full Redis command and their usage flags.
For more information see https://redis.io/commands/command-getkeysandflags
acommand_list
async
acommand_list(
module: typing.Optional[str] = None,
category: typing.Optional[str] = None,
pattern: typing.Optional[str] = None,
) -> redis.commands.core.ResponseT
Return an array of the server's command names.
You can use one of the following filters:
module
: get the commands that belong to the module
category
: get the commands in the ACL category
pattern
: get the commands that match the given pattern
For more information see https://redis.io/commands/command-list/
Source code in kvdb/components/session.py
aconfig_get
async
aconfig_get(
pattern: redis.typing.PatternT = "*",
*args: typing.List[redis.typing.PatternT],
**kwargs
) -> redis.commands.core.ResponseT
Return a dictionary of configuration based on the pattern
For more information see https://redis.io/commands/config-get
aconfig_resetstat
async
aconfig_rewrite
async
aconfig_set
async
acopy
async
acopy(
source: str,
destination: str,
destination_db: typing.Union[str, None] = None,
replace: bool = False,
) -> redis.commands.core.ResponseT
Copy the value stored in the source
key to the destination
key.
destination_db
an alternative destination database. By default,
the destination
key is created in the source Redis database.
replace
whether the destination
key should be removed before
copying the value to it. By default, the value is not copied if
the destination
key already exists.
For more information see https://redis.io/commands/copy
adbsize
async
adebug_object
async
Returns version specific meta information about a given key
For more information see https://redis.io/commands/debug-object
adecrby
async
Decrements the value of key
by amount
. If no key exists,
the value will be initialized as 0 - amount
For more information see https://redis.io/commands/decrby
adelete
async
Delete one or more keys specified by names
adelitem
async
adump
async
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 see https://redis.io/commands/dump
aecho
async
aeval
async
aeval(
script: str, numkeys: int, *keys_and_args: list
) -> typing.Union[typing.Awaitable[str], str]
Execute the Lua script
, specifying the numkeys
the script
will touch and the key names and argument values in keys_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 see https://redis.io/commands/eval
aeval_ro
async
aeval_ro(
script: str, numkeys: int, *keys_and_args: list
) -> typing.Union[typing.Awaitable[str], str]
The read-only variant of the EVAL command
Execute the read-only Lua script
specifying the numkeys
the script
will touch and the key names and argument values in keys_and_args
.
Returns the result of the script.
For more information see https://redis.io/commands/eval_ro
aevalsha
async
aevalsha(
sha: str, numkeys: int, *keys_and_args: list
) -> typing.Union[typing.Awaitable[str], str]
Use the sha
to execute a Lua script already registered via EVAL
or SCRIPT LOAD. Specify the numkeys
the script will touch and the
key names and argument values in keys_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 see https://redis.io/commands/evalsha
aevalsha_ro
async
aevalsha_ro(
sha: str, numkeys: int, *keys_and_args: list
) -> typing.Union[typing.Awaitable[str], str]
The read-only variant of the EVALSHA command
Use the sha
to execute a read-only Lua script already registered via EVAL
or SCRIPT LOAD. Specify the numkeys
the script will touch and the
key names and argument values in keys_and_args
. Returns the result
of the script.
For more information see https://redis.io/commands/evalsha_ro
aexecute_command
async
aexists
async
Returns the number of names
that exist
For more information see https://redis.io/commands/exists
aexpire
async
aexpire(
name: kvdb.types.generic.KeyT,
time: kvdb.types.generic.ExpiryT,
nx: bool = False,
xx: bool = False,
gt: bool = False,
lt: bool = False,
) -> redis.commands.core.ResponseT
Set an expire flag on key name
for time
seconds with given
option
. time
can be represented by an integer or a Python timedelta
object.
For more information see https://redis.io/commands/expire
aexpireat
async
aexpireat(
name: kvdb.types.generic.KeyT,
when: redis.typing.AbsExpiryT,
nx: bool = False,
xx: bool = False,
gt: bool = False,
lt: bool = False,
) -> redis.commands.core.ResponseT
Set an expire flag on key name
with given option
. when
can be represented as an integer indicating unix time or a Python
datetime object.
For more information see https://redis.io/commands/expireat
aexpiretime
async
Returns the absolute Unix timestamp (since January 1, 1970) in seconds at which the given key will expire.
For more information see https://redis.io/commands/expiretime
afailover
async
This function throws a NotImplementedError since it is intentionally not supported.
afcall
async
afcall(
function,
numkeys: int,
*keys_and_args: typing.Optional[typing.List]
) -> typing.Union[typing.Awaitable[str], str]
Invoke a function.
For more information see https://redis.io/commands/fcall
afcall_ro
async
afcall_ro(
function,
numkeys: int,
*keys_and_args: typing.Optional[typing.List]
) -> typing.Union[typing.Awaitable[str], str]
This is a read-only variant of the FCALL command that cannot execute commands that modify data.
For more information see https://redis.io/commands/fcal_ro
aflushall
async
Delete all keys in all databases on the current host.
asynchronous
indicates whether the operation is
executed asynchronously by the server.
For more information see https://redis.io/commands/flushall
Source code in kvdb/components/session.py
aflushdb
async
Delete all keys in the current database.
asynchronous
indicates whether the operation is
executed asynchronously by the server.
For more information see https://redis.io/commands/flushdb
afunction_delete
async
Delete the library called library
and all its functions.
For more information see https://redis.io/commands/function-delete
afunction_dump
async
Return the serialized payload of loaded libraries.
For more information see https://redis.io/commands/function-dump
afunction_flush
async
Deletes all the libraries.
For more information see https://redis.io/commands/function-flush
afunction_kill
async
Kill a function that is currently executing.
For more information see https://redis.io/commands/function-kill
afunction_list
async
afunction_list(
library: typing.Optional[str] = "*",
withcode: typing.Optional[bool] = False,
) -> typing.Union[
typing.Awaitable[typing.List], typing.List
]
Return information about the functions and libraries. :param library: pecify a pattern for matching library names :param withcode: cause the server to include the libraries source implementation in the reply
afunction_load
async
afunction_load(
code: str, replace: typing.Optional[bool] = False
) -> typing.Union[typing.Awaitable[str], str]
Load a library to Redis. :param code: the source code (must start with Shebang statement that provides a metadata about the library) :param replace: changes the behavior to overwrite the existing library with the new contents. Return the library name that was loaded.
For more information see https://redis.io/commands/function-load
afunction_restore
async
afunction_restore(
payload: str, policy: typing.Optional[str] = "APPEND"
) -> typing.Union[typing.Awaitable[str], str]
Restore libraries from the serialized payload
.
You can use the optional policy argument to provide a policy
for handling existing libraries.
For more information see https://redis.io/commands/function-restore
afunction_stats
async
Return information about the function that's currently running and information about the available execution engines.
For more information see https://redis.io/commands/function-stats
ageoadd
async
ageoadd(
name: kvdb.types.generic.KeyT,
values: typing.Sequence[redis.typing.EncodableT],
nx: bool = False,
xx: bool = False,
ch: bool = False,
) -> redis.commands.core.ResponseT
Add the specified geospatial items to the specified key identified
by the name
argument. The Geospatial items are given as ordered
members of the values
argument, each item or place is formed by
the triad longitude, latitude and name.
Note: You can use ZREM to remove elements.
nx
forces ZADD to only create new elements and not to update
scores for elements that already exist.
xx
forces ZADD to only update scores of elements that already
exist. New elements will not be added.
ch
modifies 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 see https://redis.io/commands/geoadd
ageodist
async
ageodist(
name: kvdb.types.generic.KeyT,
place1: redis.typing.FieldT,
place2: redis.typing.FieldT,
unit: typing.Union[str, None] = None,
) -> redis.commands.core.ResponseT
Return the distance between place1
and place2
members of the
name
key.
The units must be one of the following : m, km mi, ft. By default
meters are used.
For more information see https://redis.io/commands/geodist
ageohash
async
ageohash(
name: kvdb.types.generic.KeyT,
*values: redis.typing.FieldT
) -> redis.commands.core.ResponseT
Return the geo hash string for each item of values
members of
the specified key identified by the name
argument.
For more information see https://redis.io/commands/geohash
ageopos
async
ageopos(
name: kvdb.types.generic.KeyT,
*values: redis.typing.FieldT
) -> redis.commands.core.ResponseT
Return the positions of each item of values
as members of
the specified key identified by the name
argument. Each position
is represented by the pairs lon and lat.
For more information see https://redis.io/commands/geopos
ageoradius
async
ageoradius(
name: kvdb.types.generic.KeyT,
longitude: float,
latitude: float,
radius: float,
unit: typing.Union[str, None] = None,
withdist: bool = False,
withcoord: bool = False,
withhash: bool = False,
count: typing.Union[int, None] = None,
sort: typing.Union[str, None] = None,
store: typing.Union[
kvdb.types.generic.KeyT, None
] = None,
store_dist: typing.Union[
kvdb.types.generic.KeyT, None
] = None,
any: bool = False,
) -> redis.commands.core.ResponseT
Return the members of the specified key identified by the
name
argument which are within the borders of the area specified
with the latitude
and longitude
location and the maximum
distance from the center specified by the radius
value.
The units must be one of the following : m, km mi, ft. By default
withdist
indicates to return the distances of each place.
withcoord
indicates to return the latitude and longitude of
each place.
withhash
indicates to return the geohash string of each place.
count
indicates to return the number of elements up to N.
sort
indicates to return the places in a sorted way, ASC for
nearest to fairest and DESC for fairest to nearest.
store
indicates 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_dist
indicates to save the places names in a sorted set
named with a specific key, instead of store
the sorted set
destination score is set with the distance.
For more information see https://redis.io/commands/georadius
ageoradiusbymember
async
ageoradiusbymember(
name: kvdb.types.generic.KeyT,
member: redis.typing.FieldT,
radius: float,
unit: typing.Union[str, None] = None,
withdist: bool = False,
withcoord: bool = False,
withhash: bool = False,
count: typing.Union[int, None] = None,
sort: typing.Union[str, None] = None,
store: typing.Union[
kvdb.types.generic.KeyT, None
] = None,
store_dist: typing.Union[
kvdb.types.generic.KeyT, None
] = None,
any: bool = False,
) -> redis.commands.core.ResponseT
This command is exactly like georadius
with 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 see https://redis.io/commands/georadiusbymember
ageosearch
async
ageosearch(
name: kvdb.types.generic.KeyT,
member: typing.Union[redis.typing.FieldT, None] = None,
longitude: typing.Union[float, None] = None,
latitude: typing.Union[float, None] = None,
unit: str = "m",
radius: typing.Union[float, None] = None,
width: typing.Union[float, None] = None,
height: typing.Union[float, None] = None,
sort: typing.Union[str, None] = None,
count: typing.Union[int, None] = None,
any: bool = False,
withcoord: bool = False,
withdist: bool = False,
withhash: bool = False,
) -> redis.commands.core.ResponseT
Return the members of specified key identified by the
name
argument, 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.
member
Use the position of the given existing
member in the sorted set. Can't be given with longitude
and latitude
.
longitude
and latitude
Use the position given by
this coordinates. Can't be given with member
radius
Similar to GEORADIUS, search inside circular
area according the given radius. Can't be given with
height
and width
.
height
and width
Search inside an axis-aligned
rectangle, determined by the given height and width.
Can't be given with radius
unit
must 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.
sort
indicates to return the places in a sorted way,
ASC for nearest to furthest and DESC for furthest to nearest.
count
limit the results to the first count matching items.
any
is set to True, the command will return as soon as
enough matches are found. Can't be provided without count
withdist
indicates to return the distances of each place.
withcoord
indicates to return the latitude and longitude of
each place.
withhash
indicates to return the geohash string of each place.
For more information see https://redis.io/commands/geosearch
ageosearchstore
async
ageosearchstore(
dest: kvdb.types.generic.KeyT,
name: kvdb.types.generic.KeyT,
member: typing.Union[redis.typing.FieldT, None] = None,
longitude: typing.Union[float, None] = None,
latitude: typing.Union[float, None] = None,
unit: str = "m",
radius: typing.Union[float, None] = None,
width: typing.Union[float, None] = None,
height: typing.Union[float, None] = None,
sort: typing.Union[str, None] = None,
count: typing.Union[int, None] = None,
any: bool = False,
storedist: bool = False,
) -> redis.commands.core.ResponseT
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.
if store_dist
set 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 see https://redis.io/commands/geosearchstore
aget
async
Return the value at key name
, or None if the key doesn't exist
For more information see https://redis.io/commands/get
agetbit
async
Returns an integer indicating the value of offset
in name
For more information see https://redis.io/commands/getbit
agetdel
async
Get the value at key name
and 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 see https://redis.io/commands/getdel
agetex
async
agetex(
name: kvdb.types.generic.KeyT,
ex: typing.Union[
kvdb.types.generic.ExpiryT, None
] = None,
px: typing.Union[
kvdb.types.generic.ExpiryT, None
] = None,
exat: typing.Union[
redis.typing.AbsExpiryT, None
] = None,
pxat: typing.Union[
redis.typing.AbsExpiryT, None
] = None,
persist: bool = False,
) -> redis.commands.core.ResponseT
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.
ex
sets an expire flag on key name
for ex
seconds.
px
sets an expire flag on key name
for px
milliseconds.
exat
sets an expire flag on key name
for ex
seconds,
specified in unix time.
pxat
sets an expire flag on key name
for ex
milliseconds,
specified in unix time.
persist
remove the time to live associated with name
.
For more information see https://redis.io/commands/getex
agetitem
async
agetitem(
key: kvdb.types.generic.KeyT,
default: typing.Optional[typing.Any] = None,
) -> kvdb.components.session.ReturnT
[Dict] Returns the value for the given key
agetrange
async
Returns the substring of the string value stored at key
,
determined by the offsets start
and end
(both are inclusive)
For more information see https://redis.io/commands/getrange
agetset
async
agetset(
name: kvdb.types.generic.KeyT,
value: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Sets the value at key name
to value
and returns the old value at key name
atomically.
As per Redis 6.2, GETSET is considered deprecated. Please use SET with GET parameter in new code.
For more information see https://redis.io/commands/getset
ahdel
async
Delete keys
from hash name
For more information see https://redis.io/commands/hdel
ahello
async
This function throws a NotImplementedError since it is intentionally not supported.
ahexists
async
Returns a boolean indicating if key
exists within hash name
For more information see https://redis.io/commands/hexists
ahget
async
ahget(name: str, key: str) -> typing.Union[
typing.Awaitable[typing.Optional[str]],
typing.Optional[str],
]
Return the value of key
within the hash name
For more information see https://redis.io/commands/hget
ahgetall
async
Return a Python dict of the hash's name/value pairs
For more information see https://redis.io/commands/hgetall
ahincrby
async
Increment the value of key
in hash name
by amount
For more information see https://redis.io/commands/hincrby
ahincrbyfloat
async
ahincrbyfloat(
name: str, key: str, amount: float = 1.0
) -> typing.Union[typing.Awaitable[float], float]
Increment the value of key
in hash name
by floating amount
For more information see https://redis.io/commands/hincrbyfloat
ahkeys
async
Return the list of keys within hash name
For more information see https://redis.io/commands/hkeys
ahlen
async
Return the number of elements in hash name
For more information see https://redis.io/commands/hlen
ahmget
async
ahmget(
name: str, keys: typing.List, *args: typing.List
) -> typing.Union[
typing.Awaitable[typing.List], typing.List
]
Returns a list of values ordered identically to keys
For more information see https://redis.io/commands/hmget
ahmset
async
Set key to value within hash name
for each corresponding
key and value from the mapping
dict.
For more information see https://redis.io/commands/hmset
ahrandfield
async
ahrandfield(
key: str, count: int = None, withvalues: bool = False
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/hrandfield
ahscan
async
ahscan(
name: kvdb.types.generic.KeyT,
cursor: int = 0,
match: typing.Union[redis.typing.PatternT, None] = None,
count: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Incrementally return key/value slices in a hash. Also return a cursor indicating the scan position.
match
allows for filtering the keys by pattern
count
allows for hint the minimum number of returns
For more information see https://redis.io/commands/hscan
ahscan_iter
async
ahscan_iter(
name: str,
match: typing.Union[redis.typing.PatternT, None] = None,
count: typing.Union[int, None] = None,
) -> typing.AsyncIterator
Make an iterator using the HSCAN command so that the client doesn't need to remember the cursor position.
match
allows for filtering the keys by pattern
count
allows for hint the minimum number of returns
ahset
async
ahset(
name: str,
key: typing.Optional[str] = None,
value: typing.Optional[str] = None,
mapping: typing.Optional[dict] = None,
items: typing.Optional[list] = None,
) -> typing.Union[typing.Awaitable[int], int]
Set key
to value
within hash name
,
mapping
accepts a dict of key/value pairs that will be
added to hash name
.
items
accepts a list of key/value pairs that will be
added to hash name
.
Returns the number of fields that were added.
For more information see https://redis.io/commands/hset
ahsetnx
async
Set key
to value
within hash name
if key
does not
exist. Returns 1 if HSETNX created a field, otherwise 0.
For more information see https://redis.io/commands/hsetnx
ahstrlen
async
Return the number of bytes stored in the value of key
within hash name
For more information see https://redis.io/commands/hstrlen
ahvals
async
Return the list of values within hash name
For more information see https://redis.io/commands/hvals
aincrby
async
Increments the value of key
by amount
. If no key exists,
the value will be initialized as amount
For more information see https://redis.io/commands/incrby
aincrbyfloat
async
Increments the value at key name
by floating amount
.
If no key exists, the value will be initialized as amount
For more information see https://redis.io/commands/incrbyfloat
ainfo
async
ainfo(
section: typing.Union[str, None] = None,
*args: typing.List[str],
**kwargs
) -> redis.commands.core.ResponseT
Returns a dictionary containing information about the Redis server
The section
option can be used to select a specific section
of information
The section option is not supported by older versions of Redis Server, and will generate ResponseError
For more information see https://redis.io/commands/info
Source code in kvdb/components/session.py
akeys
async
Returns a list of keys matching pattern
For more information see https://redis.io/commands/keys
alastsave
async
Return a Python datetime object representing the last time the Redis database was saved to disk
For more information see https://redis.io/commands/lastsave
alatency_doctor
async
Raise a NotImplementedError, as the client will not support LATENCY DOCTOR. This funcion is best used within the redis-cli.
For more information see https://redis.io/commands/latency-doctor
alatency_graph
async
Raise a NotImplementedError, as the client will not support LATENCY GRAPH. This funcion is best used within the redis-cli.
For more information see https://redis.io/commands/latency-graph.
alatency_histogram
async
This function throws a NotImplementedError since it is intentionally not supported.
alatency_history
async
Returns the raw data of the event
's latency spikes time series.
For more information see https://redis.io/commands/latency-history
alatency_latest
async
Reports the latest latency events logged.
For more information see https://redis.io/commands/latency-latest
alatency_reset
async
Resets the latency spikes time series of all, or only some, events.
For more information see https://redis.io/commands/latency-reset
alcs
async
alcs(
key1: str,
key2: str,
len: typing.Optional[bool] = False,
idx: typing.Optional[bool] = False,
minmatchlen: typing.Optional[int] = 0,
withmatchlen: typing.Optional[bool] = False,
) -> typing.Union[str, int, list]
Find the longest common subsequence between key1
and key2
.
If len
is true the length of the match will will be returned.
If idx
is true the match position in each strings will be returned.
minmatchlen
restrict the list of matches to the ones of
the given minmatchlen
.
If withmatchlen
the length of the match also will be returned.
For more information see https://redis.io/commands/lcs
alindex
async
alindex(name: str, index: int) -> typing.Union[
typing.Awaitable[typing.Optional[str]],
typing.Optional[str],
]
Return the item from list name
at position index
Negative indexes are supported and will return an item at the end of the list
For more information see https://redis.io/commands/lindex
alinsert
async
alinsert(
name: str, where: str, refvalue: str, value: str
) -> typing.Union[typing.Awaitable[int], int]
Insert value
in list name
either immediately before or after
[where
] refvalue
Returns the new length of the list on success or -1 if refvalue
is not in the list.
For more information see https://redis.io/commands/linsert
allen
async
Return the length of the list name
For more information see https://redis.io/commands/llen
almove
async
almove(
first_list: str,
second_list: str,
src: str = "LEFT",
dest: str = "RIGHT",
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/lmove
almpop
async
almpop(
num_keys: int,
*args: typing.List[str],
direction: str,
count: typing.Optional[int] = 1
) -> typing.Union[typing.Awaitable[list], list]
Pop count
values (default 1) first non-empty list key from the list
of args provided key names.
For more information see https://redis.io/commands/lmpop
alock
alock(
name: str,
timeout: typing.Optional[
kvdb.types.generic.Number
] = None,
sleep: kvdb.types.generic.Number = 0.1,
blocking: bool = True,
blocking_timeout: typing.Optional[
kvdb.types.generic.Number
] = None,
thread_local: bool = True,
**kwargs
) -> kvdb.components.lock.AsyncLock
Create a new Lock instance named name
using the Redis client
supplied by keydb
.
timeout
indicates a maximum life for the lock in seconds.
By default, it will remain locked until release() is called.
timeout
can be specified as a float or integer, both representing
the number of seconds to wait.
sleep
indicates the amount of time to sleep in seconds per loop
iteration when the lock is in blocking mode and another client is
currently holding the lock.
blocking
indicates whether calling acquire
should block until
the lock has been acquired or to fail immediately, causing acquire
to return False and the lock not being acquired. Defaults to True.
Note this value can be overridden by passing a blocking
argument to acquire
.
blocking_timeout
indicates the maximum amount of time in seconds to
spend trying to acquire the lock. A value of None
indicates
continue trying forever. blocking_timeout
can be specified as a
float or integer, both representing the number of seconds to wait.
thread_local
indicates whether the lock token is placed in
thread-local storage. By default, the token is placed in thread local
storage so that a thread only sees its token, not a token set by
another thread.
Source code in kvdb/components/session.py
alolwut
async
alpop
async
alpop(
name: str, count: typing.Optional[int] = None
) -> typing.Union[
typing.Awaitable[typing.Union[str, typing.List, None]],
typing.Union[str, typing.List, 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 count
argument, the reply
will consist of up to count elements, depending on the list's length.
For more information see https://redis.io/commands/lpop
alpos
async
alpos(
name: str,
value: str,
rank: typing.Optional[int] = None,
count: typing.Optional[int] = None,
maxlen: typing.Optional[int] = None,
) -> typing.Union[str, typing.List, None]
Get position of value
within the list name
If specified, rank
indicates the "rank" of the first element to
return in case there are multiple copies of value
in the list.
By default, LPOS returns the position of the first occurrence of
value
in the list. When rank
2, LPOS returns the position of
the second value
in the list. If rank
is negative, LPOS
searches the list in reverse. For example, -1 would return the
position of the last occurrence of value
and -2 would return the
position of the next to last occurrence of value
.
If specified, count
indicates that LPOS should return a list of
up to count
positions. A count
of 2 would return a list of
up to 2 positions. A count
of 0 returns a list of all positions
matching value
. When count
is specified and but value
does not exist in the list, an empty list is returned.
If specified, maxlen
indicates the maximum number of list
elements to scan. A maxlen
of 1000 will only return the
position(s) of items within the first 1000 entries in the list.
A maxlen
of 0 (the default) will scan the entire list.
For more information see https://redis.io/commands/lpos
alpush
async
Push values
onto the head of the list name
For more information see https://redis.io/commands/lpush
alpushx
async
Push value
onto the head of the list name
if name
exists
For more information see https://redis.io/commands/lpushx
alrange
async
Return a slice of the list name
between
position start
and end
start
and end
can be negative numbers just like
Python slicing notation
For more information see https://redis.io/commands/lrange
alrem
async
Remove the first count
occurrences of elements equal to value
from the list stored at name
.
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 see https://redis.io/commands/lrem
alset
async
Set element at index
of list name
to value
For more information see https://redis.io/commands/lset
altrim
async
Trim the list name
, removing all values not within the slice
between start
and end
start
and end
can be negative numbers just like
Python slicing notation
For more information see https://redis.io/commands/ltrim
amemory_malloc_stats
async
Return an internal statistics report from the memory allocator.
See: https://redis.io/commands/memory-malloc-stats
amemory_purge
async
Attempts to purge dirty pages for reclamation by allocator
For more information see https://redis.io/commands/memory-purge
amemory_stats
async
Return a dictionary of memory stats
For more information see https://redis.io/commands/memory-stats
amemory_usage
async
amemory_usage(
key: kvdb.types.generic.KeyT,
samples: typing.Union[int, None] = None,
**kwargs
) -> redis.commands.core.ResponseT
Return the total memory usage for key, its value and associated administrative overheads.
For nested data structures, samples
is the number of elements to
sample. If left unspecified, the server's default is 5. Use 0 to sample
all elements.
For more information see https://redis.io/commands/memory-usage
amget
async
Returns a list of values ordered identically to keys
For more information see https://redis.io/commands/mget
amigrate
async
amigrate(
host: str,
port: int,
keys: redis.typing.KeysT,
destination_db: int,
timeout: int,
copy: bool = False,
replace: bool = False,
auth: typing.Union[str, None] = None,
**kwargs
) -> redis.commands.core.ResponseT
Migrate 1 or more keys from the current Redis server to a different
server specified by the host
, port
and destination_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 copy
is True, the specified keys
are NOT deleted from
the source server.
If replace
is True, this operation will overwrite the keys
on the destination server if they exist.
If auth
is specified, authenticate to the destination server with
the password provided.
For more information see https://redis.io/commands/migrate
amodule_list
async
Returns a list of dictionaries containing the name and version of all loaded modules.
For more information see https://redis.io/commands/module-list
amodule_load
async
Loads the module from path
.
Passes all *args
to the module, during loading.
Raises ModuleError
if a module is not found at path
.
For more information see https://redis.io/commands/module-load
amodule_loadex
async
amodule_loadex(
path: str,
options: typing.Optional[typing.List[str]] = None,
args: typing.Optional[typing.List[str]] = None,
) -> redis.commands.core.ResponseT
Loads a module from a dynamic library at runtime with configuration directives.
For more information see https://redis.io/commands/module-loadex
amodule_unload
async
Unloads the module name
.
Raises ModuleError
if name
is not in loaded modules.
For more information see https://redis.io/commands/module-unload
amove
async
Moves the key name
to a different Redis database db
For more information see https://redis.io/commands/move
amset
async
amset(
mapping: typing.Mapping[
redis.typing.AnyKeyT, redis.typing.EncodableT
]
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/mset
amsetnx
async
amsetnx(
mapping: typing.Mapping[
redis.typing.AnyKeyT, redis.typing.EncodableT
]
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/msetnx
aobject
async
Return the encoding, idletime, or refcount about the key
aoverflow
async
Update the overflow algorithm of successive INCRBY operations
:param overflow: Overflow algorithm, one of WRAP, SAT, FAIL. See the
Redis docs for descriptions of these algorithmsself.
:returns: a :py:class:BitFieldOperation
instance.
apersist
async
Removes an expiration on name
For more information see https://redis.io/commands/persist
apexpire
async
apexpire(
name: kvdb.types.generic.KeyT,
time: kvdb.types.generic.ExpiryT,
nx: bool = False,
xx: bool = False,
gt: bool = False,
lt: bool = False,
) -> redis.commands.core.ResponseT
Set an expire flag on key name
for time
milliseconds
with given option
. time
can be represented by an
integer or a Python timedelta object.
For more information see https://redis.io/commands/pexpire
apexpireat
async
apexpireat(
name: kvdb.types.generic.KeyT,
when: redis.typing.AbsExpiryT,
nx: bool = False,
xx: bool = False,
gt: bool = False,
lt: bool = False,
) -> redis.commands.core.ResponseT
Set an expire flag on key name
with given option
. when
can be represented as an integer representing unix time in
milliseconds (unix time * 1000) or a Python datetime object.
For more information see https://redis.io/commands/pexpireat
apexpiretime
async
Returns the absolute Unix timestamp (since January 1, 1970) in milliseconds at which the given key will expire.
For more information see https://redis.io/commands/pexpiretime
apfadd
async
apfadd(
name: kvdb.types.generic.KeyT,
*values: redis.typing.FieldT
) -> redis.commands.core.ResponseT
Adds the specified elements to the specified HyperLogLog.
For more information see https://redis.io/commands/pfadd
apfcount
async
Return the approximated cardinality of the set observed by the HyperLogLog at key(s).
For more information see https://redis.io/commands/pfcount
apfmerge
async
apfmerge(
dest: kvdb.types.generic.KeyT,
*sources: kvdb.types.generic.KeyT
) -> redis.commands.core.ResponseT
Merge N different HyperLogLogs into a single one.
For more information see https://redis.io/commands/pfmerge
aping
async
Ping the Redis server
For more information see https://redis.io/commands/ping
apipeline
apipeline(
transaction: typing.Optional[bool] = True,
shard_hint: typing.Optional[str] = None,
retryable: typing.Optional[bool] = None,
**kwargs
) -> kvdb.components.pipeline.AsyncPipelineT
Return a new pipeline object that can queue multiple commands for
later execution. transaction
indicates whether all commands
should be executed atomically. Apart from making a group of operations
atomic, pipelines are useful for reducing the back-and-forth overhead
between the client and server.
Source code in kvdb/components/session.py
append
append(
key: kvdb.types.generic.KeyT,
value: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Appends the string value
to the value at key
. If key
doesn't already exist, create it with a value of value
.
Returns the new length of the value at key
.
For more information see https://redis.io/commands/append
apsetex
async
apsetex(
name: kvdb.types.generic.KeyT,
time_ms: kvdb.types.generic.ExpiryT,
value: redis.typing.EncodableT,
)
Set the value of key name
to value
that expires in time_ms
milliseconds. time_ms
can be represented by an integer or a Python
timedelta object
For more information see https://redis.io/commands/psetex
apsync
async
Initiates a replication stream from the master.
Newer version for sync
.
For more information see https://redis.io/commands/sync
apttl
async
Returns the number of milliseconds until the key name
will expire
For more information see https://redis.io/commands/pttl
apublish
async
apublish(
channel: redis.typing.ChannelT,
message: redis.typing.EncodableT,
**kwargs
) -> redis.commands.core.ResponseT
Publish message
on channel
.
Returns the number of subscribers the message was delivered to.
For more information see https://redis.io/commands/publish
apubsub
Return a Publish/Subscribe object. With this object, you can subscribe to channels and listen for messages that get published to
Source code in kvdb/components/session.py
apubsub_channels
async
Return a list of channels that have at least one subscriber
For more information see https://redis.io/commands/pubsub-channels
apubsub_numpat
async
Returns the number of subscriptions to patterns
For more information see https://redis.io/commands/pubsub-numpat
apubsub_numsub
async
Return a list of (channel, number of subscribers) tuples
for each channel given in *args
For more information see https://redis.io/commands/pubsub-numsub
apubsub_shardchannels
async
apubsub_shardchannels(
pattern: redis.typing.PatternT = "*", **kwargs
) -> redis.commands.core.ResponseT
Return a list of shard_channels that have at least one subscriber
For more information see https://redis.io/commands/pubsub-shardchannels
apubsub_shardnumsub
async
Return a list of (shard_channel, number of subscribers) tuples
for each channel given in *args
For more information see https://redis.io/commands/pubsub-shardnumsub
aquit
async
Ask the server to close the connection.
For more information see https://redis.io/commands/quit
arandomkey
async
Returns the name of a random key
For more information see https://redis.io/commands/randomkey
areadonly
async
Enables read queries for a connection to a Redis Cluster replica node.
For more information see https://redis.io/commands/readonly
areadwrite
async
Disables read queries for a connection to a Redis Cluster slave node.
For more information see https://redis.io/commands/readwrite
aregister_script
async
Register a Lua script
specifying the keys
it 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.
arename
async
arename(
src: kvdb.types.generic.KeyT,
dst: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT
Rename key src
to dst
For more information see https://redis.io/commands/rename
arenamenx
async
Rename key src
to dst
if dst
doesn't already exist
For more information see https://redis.io/commands/renamenx
areplicaof
async
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 see https://redis.io/commands/replicaof
arestore
async
arestore(
name: kvdb.types.generic.KeyT,
ttl: float,
value: redis.typing.EncodableT,
replace: bool = False,
absttl: bool = False,
idletime: typing.Union[int, None] = None,
frequency: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Create a key using the provided serialized value, previously obtained using DUMP.
replace
allows an existing key on name
to be overridden. If
it's not specified an error is raised on collision.
absttl
if True, specified ttl
should represent an absolute Unix
timestamp in milliseconds in which the key will expire. (Redis 5.0 or
greater).
idletime
Used for eviction, this is the number of seconds the
key must be idle, prior to execution.
frequency
Used for eviction, this is the frequency counter of
the object stored at the key, prior to execution.
For more information see https://redis.io/commands/restore
arole
async
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 see https://redis.io/commands/role
Source code in kvdb/components/session.py
arpop
async
arpop(
name: str, count: typing.Optional[int] = None
) -> typing.Union[
typing.Awaitable[typing.Union[str, typing.List, None]],
typing.Union[str, typing.List, 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 count
argument, the reply will
consist of up to count elements, depending on the list's length.
For more information see https://redis.io/commands/rpop
arpoplpush
async
RPOP a value off of the src
list and atomically LPUSH it
on to the dst
list. Returns the value.
For more information see https://redis.io/commands/rpoplpush
arpush
async
Push values
onto the tail of the list name
For more information see https://redis.io/commands/rpush
arpushx
async
Push value
onto the tail of the list name
if name
exists
For more information see https://redis.io/commands/rpushx
asadd
async
Add value(s)
to set name
For more information see https://redis.io/commands/sadd
asave
async
Tell the Redis server to save its data to disk, blocking until the save is complete
For more information see https://redis.io/commands/save
ascan
async
ascan(
cursor: int = 0,
match: typing.Union[redis.typing.PatternT, None] = None,
count: typing.Union[int, None] = None,
_type: typing.Union[str, None] = None,
**kwargs
) -> redis.commands.core.ResponseT
Incrementally return lists of key names. Also return a cursor indicating the scan position.
match
allows for filtering the keys by pattern
count
provides a hint to Redis about the number of keys to
return per batch.
_type
filters 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 see https://redis.io/commands/scan
ascan_iter
async
ascan_iter(
match: typing.Union[redis.typing.PatternT, None] = None,
count: typing.Union[int, None] = None,
_type: typing.Union[str, None] = None,
**kwargs
) -> typing.AsyncIterator
Make an iterator using the SCAN command so that the client doesn't need to remember the cursor position.
match
allows for filtering the keys by pattern
count
provides a hint to Redis about the number of keys to
return per batch.
_type
filters 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.
ascard
async
Return the number of elements in set name
For more information see https://redis.io/commands/scard
ascript_exists
async
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 see https://redis.io/commands/script-exists
ascript_flush
async
ascript_flush(
sync_type: typing.Union[
typing.Literal["SYNC"], typing.Literal["ASYNC"]
] = None
) -> redis.commands.core.ResponseT
Flush all scripts from the script cache.
sync_type
is by default SYNC (synchronous) but it can also be
ASYNC.
For more information see https://redis.io/commands/script-flush
ascript_kill
async
Kill the currently executing Lua script
For more information see https://redis.io/commands/script-kill
ascript_load
async
Load a Lua script
into the script cache. Returns the SHA.
For more information see https://redis.io/commands/script-load
asdiff
async
Return the difference of sets specified by keys
For more information see https://redis.io/commands/sdiff
asdiffstore
async
asdiffstore(
dest: str, keys: typing.List, *args: typing.List
) -> typing.Union[typing.Awaitable[int], int]
Store the difference of sets specified by keys
into a new
set named dest
. Returns the number of keys in the new set.
For more information see https://redis.io/commands/sdiffstore
aselect
async
aset
async
aset(
name: kvdb.types.generic.KeyT,
value: redis.typing.EncodableT,
ex: typing.Union[
kvdb.types.generic.ExpiryT, None
] = None,
px: typing.Union[
kvdb.types.generic.ExpiryT, None
] = None,
nx: bool = False,
xx: bool = False,
keepttl: bool = False,
get: bool = False,
exat: typing.Union[
redis.typing.AbsExpiryT, None
] = None,
pxat: typing.Union[
redis.typing.AbsExpiryT, None
] = None,
) -> redis.commands.core.ResponseT
Set the value at key name
to value
ex
sets an expire flag on key name
for ex
seconds.
px
sets an expire flag on key name
for px
milliseconds.
nx
if set to True, set the value at key name
to value
only
if it does not exist.
xx
if set to True, set the value at key name
to value
only
if it already exists.
keepttl
if True, retain the time to live associated with the key.
(Available since Redis 6.0)
get
if True, set the value at key name
to value
and return
the old value stored at key, or None if the key did not exist.
(Available since Redis 6.2)
exat
sets an expire flag on key name
for ex
seconds,
specified in unix time.
pxat
sets an expire flag on key name
for ex
milliseconds,
specified in unix time.
For more information see https://redis.io/commands/set
asetbit
async
Flag the offset
in name
as value
. Returns an integer
indicating the previous value of offset
.
For more information see https://redis.io/commands/setbit
asetex
async
asetex(
name: kvdb.types.generic.KeyT,
time: kvdb.types.generic.ExpiryT,
value: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Set the value of key name
to value
that expires in time
seconds. time
can be represented by an integer or a Python
timedelta object.
For more information see https://redis.io/commands/setex
asetitem
async
asetitem(
key: kvdb.types.generic.KeyT,
value: typing.Any,
ex: typing.Optional[kvdb.types.generic.ExpiryT] = None,
**kwargs: typing.Any
) -> None
[Dict] Sets the value for the given key
Source code in kvdb/components/session.py
asetnx
async
asetnx(
name: kvdb.types.generic.KeyT,
value: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Set the value of key name
to value
if key doesn't exist
For more information see https://redis.io/commands/setnx
asetrange
async
asetrange(
name: kvdb.types.generic.KeyT,
offset: int,
value: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Overwrite bytes in the value of name
starting at offset
with
value
. If offset
plus the length of value
exceeds the
length of the original value, the new value will be larger than before.
If offset
exceeds 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 see https://redis.io/commands/setrange
ashutdown
async
ashutdown(
save: bool = False,
nosave: bool = False,
now: bool = False,
force: bool = False,
abort: bool = False,
**kwargs
) -> None
Shutdown the Redis server. If Redis has persistence configured,
data will be flushed before shutdown.
It is possible to specify modifiers to alter the behavior of the command:
save
will force a DB saving operation even if no save points are configured.
nosave
will prevent a DB saving operation even if one or more save points
are configured.
now
skips waiting for lagging replicas, i.e. it bypasses the first step in
the shutdown sequence.
force
ignores any errors that would normally prevent the server from exiting
abort
cancels an ongoing shutdown and cannot be combined with other flags.
For more information see https://redis.io/commands/shutdown
asinter
async
Return the intersection of sets specified by keys
For more information see https://redis.io/commands/sinter
asintercard
async
asintercard(
numkeys: int, keys: typing.List[str], limit: int = 0
) -> typing.Union[typing.Awaitable[int], int]
Return the cardinality of the intersect of multiple sets specified by `keys
.
When LIMIT provided (defaults to 0 and means unlimited), if the intersection cardinality reaches limit partway through the computation, the algorithm will exit and yield limit as the cardinality
For more information see https://redis.io/commands/sintercard
asinterstore
async
asinterstore(
dest: str, keys: typing.List, *args: typing.List
) -> typing.Union[typing.Awaitable[int], int]
Store the intersection of sets specified by keys
into a new
set named dest
. Returns the number of keys in the new set.
For more information see https://redis.io/commands/sinterstore
asismember
async
asismember(name: str, value: str) -> typing.Union[
typing.Awaitable[
typing.Union[typing.Literal[0], typing.Literal[1]]
],
typing.Union[typing.Literal[0], typing.Literal[1]],
]
Return whether value
is a member of set name
:
- 1 if the value is a member of the set.
- 0 if the value is not a member of the set or if key does not exist.
For more information see https://redis.io/commands/sismember
aslaveof
async
aslaveof(
host: typing.Union[str, None] = None,
port: typing.Union[int, None] = None,
**kwargs
) -> redis.commands.core.ResponseT
Set the server to be a replicated slave of the instance identified
by the host
and port
. If called without arguments, the
instance is promoted to a master instead.
For more information see https://redis.io/commands/slaveof
aslowlog_get
async
Get the entries from the slowlog. If num
is specified, get the
most recent num
items.
For more information see https://redis.io/commands/slowlog-get
aslowlog_len
async
Get the number of items in the slowlog
For more information see https://redis.io/commands/slowlog-len
aslowlog_reset
async
Remove all items in the slowlog
For more information see https://redis.io/commands/slowlog-reset
asmembers
async
Return all members of the set name
For more information see https://redis.io/commands/smembers
asmismember
async
asmismember(
name: str, values: typing.List, *args: typing.List
) -> typing.Union[
typing.Awaitable[
typing.List[
typing.Union[
typing.Literal[0], typing.Literal[1]
]
]
],
typing.List[
typing.Union[typing.Literal[0], typing.Literal[1]]
],
]
Return whether each value in values
is a member of the set name
as a list of int
in the order of values
:
- 1 if the value is a member of the set.
- 0 if the value is not a member of the set or if key does not exist.
For more information see https://redis.io/commands/smismember
asmove
async
Move value
from set src
to set dst
atomically
For more information see https://redis.io/commands/smove
asort
async
asort(
name: str,
start: typing.Optional[int] = None,
num: typing.Optional[int] = None,
by: typing.Optional[str] = None,
get: typing.Optional[typing.List[str]] = None,
desc: bool = False,
alpha: bool = False,
store: typing.Optional[str] = None,
groups: typing.Optional[bool] = False,
) -> typing.Union[typing.List, int]
Sort and return the list, set or sorted set at name
.
start
and num
allow for paging through the sorted data
by
allows using an external key to weight and sort the items.
Use an "*" to indicate where in the key the item value is located
get
allows 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
desc
allows for reversing the sort
alpha
allows for sorting lexicographically rather than numerically
store
allows for storing the result of the sort into
the key store
groups
if set to True and if get
contains at least two
elements, sort will return a list of tuples, each containing the
values fetched from the arguments to get
.
For more information see https://redis.io/commands/sort
asort_ro
async
asort_ro(
key: str,
start: typing.Optional[int] = None,
num: typing.Optional[int] = None,
by: typing.Optional[str] = None,
get: typing.Optional[typing.List[str]] = None,
desc: bool = False,
alpha: bool = False,
) -> list
Returns the elements contained in the list, set or sorted set at key. (read-only variant of the SORT command)
start
and num
allow for paging through the sorted data
by
allows using an external key to weight and sort the items.
Use an "*" to indicate where in the key the item value is located
get
allows 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
desc
allows for reversing the sort
alpha
allows for sorting lexicographically rather than numerically
For more information see https://redis.io/commands/sort_ro
aspop
async
Remove and return a random member of set name
For more information see https://redis.io/commands/spop
aspublish
async
aspublish(
shard_channel: redis.typing.ChannelT,
message: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Posts a message to the given shard channel. Returns the number of clients that received the message
For more information see https://redis.io/commands/spublish
asrandmember
async
asrandmember(
name: str, number: typing.Optional[int] = None
) -> typing.Union[str, typing.List, None]
If number
is None, returns a random member of set name
.
If number
is supplied, returns a list of number
random
members of set name
. Note this is only available when running
Redis 2.6+.
For more information see https://redis.io/commands/srandmember
asrem
async
Remove values
from set name
For more information see https://redis.io/commands/srem
asscan
async
asscan(
name: kvdb.types.generic.KeyT,
cursor: int = 0,
match: typing.Union[redis.typing.PatternT, None] = None,
count: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Incrementally return lists of elements in a set. Also return a cursor indicating the scan position.
match
allows for filtering the keys by pattern
count
allows for hint the minimum number of returns
For more information see https://redis.io/commands/sscan
asscan_iter
async
asscan_iter(
name: kvdb.types.generic.KeyT,
match: typing.Union[redis.typing.PatternT, None] = None,
count: typing.Union[int, None] = None,
) -> typing.AsyncIterator
Make an iterator using the SSCAN command so that the client doesn't need to remember the cursor position.
match
allows for filtering the keys by pattern
count
allows for hint the minimum number of returns
astralgo
async
astralgo(
algo: typing.Literal["LCS"],
value1: kvdb.types.generic.KeyT,
value2: kvdb.types.generic.KeyT,
specific_argument: typing.Union[
typing.Literal["strings"], typing.Literal["keys"]
] = "strings",
len: bool = False,
idx: bool = False,
minmatchlen: typing.Union[int, None] = None,
withmatchlen: bool = False,
**kwargs
) -> redis.commands.core.ResponseT
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.
algo
Right now must be LCS
value1
and value2
Can be two strings or two keys
specific_argument
Specifying if the arguments to the algorithm
will be keys or strings. strings is the default.
len
Returns just the len of the match.
idx
Returns the match positions in each string.
minmatchlen
Restrict the list of matches to the ones of a given
minimal length. Can be provided only when idx
set to True.
withmatchlen
Returns the matches with the len of the match.
Can be provided only when idx
set to True.
For more information see https://redis.io/commands/stralgo
astrlen
async
Return the number of bytes stored in the value of name
For more information see https://redis.io/commands/strlen
asubstr
async
asubstr(
name: kvdb.types.generic.KeyT, start: int, end: int = -1
) -> redis.commands.core.ResponseT
Return a substring of the string at key name
. start
and end
are 0-based integers specifying the portion of the string to return.
asunion
async
asunion(
keys: typing.List, *args: typing.List
) -> typing.Union[
typing.Awaitable[typing.List], typing.List
]
Return the union of sets specified by keys
For more information see https://redis.io/commands/sunion
asunionstore
async
asunionstore(
dest: str, keys: typing.List, *args: typing.List
) -> typing.Union[typing.Awaitable[int], int]
Store the union of sets specified by keys
into a new
set named dest
. Returns the number of keys in the new set.
For more information see https://redis.io/commands/sunionstore
aswapdb
async
Swap two databases
For more information see https://redis.io/commands/swapdb
async_
async
atfcall
async
atfcall(
lib_name: str,
func_name: str,
keys: redis.typing.KeysT = None,
*args: typing.List
) -> redis.commands.core.ResponseT
Invoke a function.
lib_name
- the library name contains the function.
func_name
- the function name to run.
keys
- the keys that will be touched by the function.
args
- Additional argument to pass to the function.
For more information see https://redis.io/commands/tfcall/
atfcall_async
async
atfcall_async(
lib_name: str,
func_name: str,
keys: redis.typing.KeysT = None,
*args: typing.List
) -> redis.commands.core.ResponseT
Invoke an async function (coroutine).
lib_name
- the library name contains the function.
func_name
- the function name to run.
keys
- the keys that will be touched by the function.
args
- Additional argument to pass to the function.
For more information see https://redis.io/commands/tfcall/
atfunction_delete
async
Delete a library from RedisGears.
lib_name
the library name to delete.
For more information see https://redis.io/commands/tfunction-delete/
atfunction_list
async
atfunction_list(
with_code: bool = False,
verbose: int = 0,
lib_name: typing.Union[str, None] = None,
) -> redis.commands.core.ResponseT
List the functions with additional information about each function.
with_code
Show libraries code.
verbose
output verbosity level, higher number will increase verbosity level
lib_name
specifying a library name (can be used multiple times to show multiple libraries in a single command) # noqa
For more information see https://redis.io/commands/tfunction-list/
atfunction_load
async
atfunction_load(
lib_code: str,
replace: bool = False,
config: typing.Union[str, None] = None,
) -> redis.commands.core.ResponseT
Load a new library to RedisGears.
lib_code
- the library code.
config
- a string representation of a JSON object
that will be provided to the library on load time,
for more information refer to
https://github.com/RedisGears/RedisGears/blob/master/docs/function_advance_topics.md#library-configuration
replace
- an optional argument, instructs RedisGears to replace the
function if its already exists
For more information see https://redis.io/commands/tfunction-load/
atime
async
Returns the server time as a 2-item tuple of ints: (seconds since epoch, microseconds into this second).
For more information see https://redis.io/commands/time
atouch
async
Alters the last access time of a key(s) *args
. A key is ignored
if it does not exist.
For more information see https://redis.io/commands/touch
attl
async
Returns the number of seconds until the key name
will expire
For more information see https://redis.io/commands/ttl
atype
async
Returns the type of key name
For more information see https://redis.io/commands/type
aunlink
async
Unlink one or more keys specified by names
For more information see https://redis.io/commands/unlink
aunwatch
async
Unwatches the value at key name
, or None of the key doesn't exist
For more information see https://redis.io/commands/unwatch
auth
Authenticates the user. If you do not pass username, Redis will try to authenticate for the "default" user. If you do pass username, it will authenticate for the given user. For more information see https://redis.io/commands/auth
await_
async
Redis synchronous replication
That returns the number of replicas that processed the query when
we finally have at least num_replicas
, or when the timeout
was
reached.
For more information see https://redis.io/commands/wait
awaitaof
async
awaitaof(
num_local: int,
num_replicas: int,
timeout: int,
**kwargs
) -> redis.commands.core.ResponseT
This command blocks the current client until all previous write commands by that client are acknowledged as having been fsynced to the AOF of the local Redis and/or at least the specified number of replicas.
For more information see https://redis.io/commands/waitaof
awatch
async
Watches the values at keys names
, or None if the key doesn't exist
For more information see https://redis.io/commands/watch
axack
async
axack(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
*ids: redis.typing.StreamIdT
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/xack
axadd
async
axadd(
name: kvdb.types.generic.KeyT,
fields: typing.Dict[
redis.typing.FieldT, redis.typing.EncodableT
],
id: redis.typing.StreamIdT = "*",
maxlen: typing.Union[int, None] = None,
approximate: bool = True,
nomkstream: bool = False,
minid: typing.Union[
redis.typing.StreamIdT, None
] = None,
limit: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/xadd
axautoclaim
async
axautoclaim(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
consumername: redis.typing.ConsumerT,
min_idle_time: int,
start_id: redis.typing.StreamIdT = "0-0",
count: typing.Union[int, None] = None,
justid: bool = False,
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/xautoclaim
axclaim
async
axclaim(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
consumername: redis.typing.ConsumerT,
min_idle_time: int,
message_ids: typing.Union[
typing.List[redis.typing.StreamIdT],
typing.Tuple[redis.typing.StreamIdT],
],
idle: typing.Union[int, None] = None,
time: typing.Union[int, None] = None,
retrycount: typing.Union[int, None] = None,
force: bool = False,
justid: bool = False,
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/xclaim
axdel
async
axdel(
name: kvdb.types.generic.KeyT,
*ids: redis.typing.StreamIdT
) -> redis.commands.core.ResponseT
Deletes one or more messages from a stream. name: name of the stream. *ids: message ids to delete.
For more information see https://redis.io/commands/xdel
axgroup_create
async
axgroup_create(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
id: redis.typing.StreamIdT = "$",
mkstream: bool = False,
entries_read: typing.Optional[int] = None,
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/xgroup-create
axgroup_createconsumer
async
axgroup_createconsumer(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
consumername: redis.typing.ConsumerT,
) -> redis.commands.core.ResponseT
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.
See: https://redis.io/commands/xgroup-createconsumer
axgroup_delconsumer
async
axgroup_delconsumer(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
consumername: redis.typing.ConsumerT,
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/xgroup-delconsumer
axgroup_destroy
async
axgroup_destroy(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
) -> redis.commands.core.ResponseT
Destroy a consumer group. name: name of the stream. groupname: name of the consumer group.
For more information see https://redis.io/commands/xgroup-destroy
axgroup_setid
async
axgroup_setid(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
id: redis.typing.StreamIdT,
entries_read: typing.Optional[int] = None,
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/xgroup-setid
axinfo_consumers
async
axinfo_consumers(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
) -> redis.commands.core.ResponseT
Returns general information about the consumers in the group. name: name of the stream. groupname: name of the consumer group.
For more information see https://redis.io/commands/xinfo-consumers
axinfo_groups
async
Returns general information about the consumer groups of the stream. name: name of the stream.
For more information see https://redis.io/commands/xinfo-groups
axinfo_stream
async
Returns general information about the stream. name: name of the stream. full: optional boolean, false by default. Return full summary
For more information see https://redis.io/commands/xinfo-stream
axlen
async
Returns the number of elements in a given stream.
For more information see https://redis.io/commands/xlen
axpending
async
axpending(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
) -> redis.commands.core.ResponseT
Returns information about pending messages of a group. name: name of the stream. groupname: name of the consumer group.
For more information see https://redis.io/commands/xpending
axpending_range
async
axpending_range(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
min: redis.typing.StreamIdT,
max: redis.typing.StreamIdT,
count: int,
consumername: typing.Union[
redis.typing.ConsumerT, None
] = None,
idle: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
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).
axrange
async
axrange(
name: kvdb.types.generic.KeyT,
min: redis.typing.StreamIdT = "-",
max: redis.typing.StreamIdT = "+",
count: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Read stream values within an interval.
name: name of the stream.
first stream ID. defaults to '-',
meaning the earliest available.
last stream ID. defaults to '+',
meaning the latest available.
if set, only return this many items, beginning with the
earliest available.
For more information see https://redis.io/commands/xrange
axread
async
axread(
streams: typing.Dict[
kvdb.types.generic.KeyT, redis.typing.StreamIdT
],
count: typing.Union[int, None] = None,
block: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Block and monitor multiple streams for new data.
a dict of stream names to stream IDs, where
IDs indicate the last ID already seen.
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 see https://redis.io/commands/xread
axreadgroup
async
axreadgroup(
groupname: str,
consumername: str,
streams: typing.Dict[
kvdb.types.generic.KeyT, redis.typing.StreamIdT
],
count: typing.Union[int, None] = None,
block: typing.Union[int, None] = None,
noack: bool = False,
) -> redis.commands.core.ResponseT
Read from a stream via a consumer group.
groupname: name of the consumer group.
consumername: name of the requesting consumer.
a dict of stream names to stream IDs, where
IDs indicate the last ID already seen.
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 see https://redis.io/commands/xreadgroup
axrevrange
async
axrevrange(
name: kvdb.types.generic.KeyT,
max: redis.typing.StreamIdT = "+",
min: redis.typing.StreamIdT = "-",
count: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Read stream values within an interval, in reverse order.
name: name of the stream
first stream ID. defaults to '+',
meaning the latest available.
last stream ID. defaults to '-',
meaning the earliest available.
if set, only return this many items, beginning with the
latest available.
For more information see https://redis.io/commands/xrevrange
axtrim
async
axtrim(
name: kvdb.types.generic.KeyT,
maxlen: typing.Union[int, None] = None,
approximate: bool = True,
minid: typing.Union[
redis.typing.StreamIdT, None
] = None,
limit: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/xtrim
azadd
async
azadd(
name: kvdb.types.generic.KeyT,
mapping: typing.Mapping[
redis.typing.AnyKeyT, redis.typing.EncodableT
],
nx: bool = False,
xx: bool = False,
ch: bool = False,
incr: bool = False,
gt: bool = False,
lt: bool = False,
) -> redis.commands.core.ResponseT
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.
nx
forces ZADD to only create new elements and not to update
scores for elements that already exist.
xx
forces ZADD to only update scores of elements that already
exist. New elements will not be added.
ch
modifies the return value to be the numbers of elements changed.
Changed elements include new elements that were added and elements
whose scores changed.
incr
modifies 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.
LT
Only update existing elements if the new score is less than
the current score. This flag doesn't prevent adding new elements.
GT
Only 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
, and GT
are mutually exclusive options.
See: https://redis.io/commands/ZADD
azcard
async
Return the number of elements in the sorted set name
For more information see https://redis.io/commands/zcard
azcount
async
azcount(
name: kvdb.types.generic.KeyT,
min: redis.typing.ZScoreBoundT,
max: redis.typing.ZScoreBoundT,
) -> redis.commands.core.ResponseT
Returns the number of elements in the sorted set at key name
with
a score between min
and max
.
For more information see https://redis.io/commands/zcount
azdiff
async
Returns the difference between the first and all successive input
sorted sets provided in keys
.
For more information see https://redis.io/commands/zdiff
azdiffstore
async
azdiffstore(
dest: kvdb.types.generic.KeyT, keys: redis.typing.KeysT
) -> redis.commands.core.ResponseT
Computes the difference between the first and all successive input
sorted sets provided in keys
and stores the result in dest
.
For more information see https://redis.io/commands/zdiffstore
azincrby
async
azincrby(
name: kvdb.types.generic.KeyT,
amount: float,
value: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Increment the score of value
in sorted set name
by amount
For more information see https://redis.io/commands/zincrby
azinter
async
azinter(
keys: redis.typing.KeysT,
aggregate: typing.Union[str, None] = None,
withscores: bool = False,
) -> redis.commands.core.ResponseT
Return the intersect of multiple sorted sets specified by keys
.
With the aggregate
option, 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 see https://redis.io/commands/zinter
azintercard
async
azintercard(
numkeys: int, keys: typing.List[str], limit: int = 0
) -> typing.Union[typing.Awaitable[int], int]
Return the cardinality of the intersect of multiple sorted sets
specified by `keys
.
When LIMIT provided (defaults to 0 and means unlimited), if the intersection
cardinality reaches limit partway through the computation, the algorithm will
exit and yield limit as the cardinality
For more information see https://redis.io/commands/zintercard
azinterstore
async
azinterstore(
dest: kvdb.types.generic.KeyT,
keys: typing.Union[
typing.Sequence[kvdb.types.generic.KeyT],
typing.Mapping[redis.typing.AnyKeyT, float],
],
aggregate: typing.Union[str, None] = None,
) -> redis.commands.core.ResponseT
Intersect multiple sorted sets specified by keys
into a new
sorted set, dest
. Scores in the destination will be aggregated
based on the aggregate
. 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 see https://redis.io/commands/zinterstore
azlexcount
async
Return the number of items in the sorted set name
between the
lexicographical range min
and max
.
For more information see https://redis.io/commands/zlexcount
azmpop
async
azmpop(
num_keys: int,
keys: typing.List[str],
min: typing.Optional[bool] = False,
max: typing.Optional[bool] = False,
count: typing.Optional[int] = 1,
) -> typing.Union[typing.Awaitable[list], list]
Pop count
values (default 1) off of the first non-empty sorted set
named in the keys
list.
For more information see https://redis.io/commands/zmpop
azmscore
async
azmscore(
key: kvdb.types.generic.KeyT, members: typing.List[str]
) -> redis.commands.core.ResponseT
Returns the scores associated with the specified members
in the sorted set stored at key.
members
should 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 see https://redis.io/commands/zmscore
azpopmax
async
azpopmax(
name: kvdb.types.generic.KeyT,
count: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Remove and return up to count
members with the highest scores
from the sorted set name
.
For more information see https://redis.io/commands/zpopmax
azpopmin
async
azpopmin(
name: kvdb.types.generic.KeyT,
count: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Remove and return up to count
members with the lowest scores
from the sorted set name
.
For more information see https://redis.io/commands/zpopmin
azrandmember
async
azrandmember(
key: kvdb.types.generic.KeyT,
count: int = None,
withscores: bool = False,
) -> redis.commands.core.ResponseT
Return a random element from the sorted set 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.
withscores
The optional WITHSCORES modifier changes the reply so it
includes the respective scores of the randomly selected elements from
the sorted set.
For more information see https://redis.io/commands/zrandmember
azrange
async
azrange(
name: kvdb.types.generic.KeyT,
start: int,
end: int,
desc: bool = False,
withscores: bool = False,
score_cast_func: typing.Union[
kvdb.components.session.KVDBSession.type,
typing.Callable,
] = ...,
byscore: bool = False,
bylex: bool = False,
offset: int = None,
num: int = None,
) -> redis.commands.core.ResponseT
Return a range of values from sorted set name
between
start
and end
sorted in ascending order.
start
and end
can be negative, indicating the end of the range.
desc
a boolean indicating whether to sort the results in reversed
order.
withscores
indicates to return the scores along with the values.
The return type is a list of (value, score) pairs.
score_cast_func
a callable used to cast the score return value.
byscore
when set to True, returns the range of elements from the
sorted set having scores equal or between start
and end
.
bylex
when set to True, returns the range of elements from the
sorted set between the start
and end
lexicographical closed
range intervals.
Valid start
and end
must start with ( or [, in order to specify
whether the range interval is exclusive or inclusive, respectively.
offset
and num
are specified, then return a slice of the range.
Can't be provided when using bylex
.
For more information see https://redis.io/commands/zrange
azrangebylex
async
azrangebylex(
name: kvdb.types.generic.KeyT,
min: redis.typing.EncodableT,
max: redis.typing.EncodableT,
start: typing.Union[int, None] = None,
num: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Return the lexicographical range of values from sorted set name
between min
and max
.
If start
and num
are specified, then return a slice of the
range.
For more information see https://redis.io/commands/zrangebylex
azrangebyscore
async
azrangebyscore(
name: kvdb.types.generic.KeyT,
min: redis.typing.ZScoreBoundT,
max: redis.typing.ZScoreBoundT,
start: typing.Union[int, None] = None,
num: typing.Union[int, None] = None,
withscores: bool = False,
score_cast_func: typing.Union[
kvdb.components.session.KVDBSession.type,
typing.Callable,
] = ...,
) -> redis.commands.core.ResponseT
Return a range of values from the sorted set name
with scores
between min
and max
.
If start
and num
are specified, then return a slice
of the range.
withscores
indicates to return the scores along with the values.
The return type is a list of (value, score) pairs
`score_cast_func`` a callable used to cast the score return value
For more information see https://redis.io/commands/zrangebyscore
azrangestore
async
azrangestore(
dest: kvdb.types.generic.KeyT,
name: kvdb.types.generic.KeyT,
start: int,
end: int,
byscore: bool = False,
bylex: bool = False,
desc: bool = False,
offset: typing.Union[int, None] = None,
num: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Stores in dest
the result of a range of values from sorted set
name
between start
and end
sorted in ascending order.
start
and end
can be negative, indicating the end of the range.
byscore
when set to True, returns the range of elements from the
sorted set having scores equal or between start
and end
.
bylex
when set to True, returns the range of elements from the
sorted set between the start
and end
lexicographical closed
range intervals.
Valid start
and end
must start with ( or [, in order to specify
whether the range interval is exclusive or inclusive, respectively.
desc
a boolean indicating whether to sort the results in reversed
order.
offset
and num
are specified, then return a slice of the range.
Can't be provided when using bylex
.
For more information see https://redis.io/commands/zrangestore
azrank
async
azrank(
name: kvdb.types.generic.KeyT,
value: redis.typing.EncodableT,
withscore: bool = False,
) -> redis.commands.core.ResponseT
Returns a 0-based value indicating the rank of value
in sorted set
name
.
The optional WITHSCORE argument supplements the command's
reply with the score of the element returned.
For more information see https://redis.io/commands/zrank
azrem
async
azrem(
name: kvdb.types.generic.KeyT,
*values: redis.typing.FieldT
) -> redis.commands.core.ResponseT
Remove member values
from sorted set name
For more information see https://redis.io/commands/zrem
azremrangebylex
async
azremrangebylex(
name: kvdb.types.generic.KeyT,
min: redis.typing.EncodableT,
max: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Remove all elements in the sorted set name
between the
lexicographical range specified by min
and max
.
Returns the number of elements removed.
For more information see https://redis.io/commands/zremrangebylex
azremrangebyrank
async
azremrangebyrank(
name: kvdb.types.generic.KeyT, min: int, max: int
) -> redis.commands.core.ResponseT
Remove all elements in the sorted set name
with ranks between
min
and max
. Values are 0-based, ordered from smallest score
to largest. Values can be negative indicating the highest scores.
Returns the number of elements removed
For more information see https://redis.io/commands/zremrangebyrank
azremrangebyscore
async
azremrangebyscore(
name: kvdb.types.generic.KeyT,
min: redis.typing.ZScoreBoundT,
max: redis.typing.ZScoreBoundT,
) -> redis.commands.core.ResponseT
Remove all elements in the sorted set name
with scores
between min
and max
. Returns the number of elements removed.
For more information see https://redis.io/commands/zremrangebyscore
azrevrange
async
azrevrange(
name: kvdb.types.generic.KeyT,
start: int,
end: int,
withscores: bool = False,
score_cast_func: typing.Union[
kvdb.components.session.KVDBSession.type,
typing.Callable,
] = ...,
) -> redis.commands.core.ResponseT
Return a range of values from sorted set name
between
start
and end
sorted in descending order.
start
and end
can be negative, indicating the end of the range.
withscores
indicates to return the scores along with the values
The return type is a list of (value, score) pairs
score_cast_func
a callable used to cast the score return value
For more information see https://redis.io/commands/zrevrange
azrevrangebylex
async
azrevrangebylex(
name: kvdb.types.generic.KeyT,
max: redis.typing.EncodableT,
min: redis.typing.EncodableT,
start: typing.Union[int, None] = None,
num: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Return the reversed lexicographical range of values from sorted set
name
between max
and min
.
If start
and num
are specified, then return a slice of the
range.
For more information see https://redis.io/commands/zrevrangebylex
azrevrangebyscore
async
azrevrangebyscore(
name: kvdb.types.generic.KeyT,
max: redis.typing.ZScoreBoundT,
min: redis.typing.ZScoreBoundT,
start: typing.Union[int, None] = None,
num: typing.Union[int, None] = None,
withscores: bool = False,
score_cast_func: typing.Union[
kvdb.components.session.KVDBSession.type,
typing.Callable,
] = ...,
)
Return a range of values from the sorted set name
with scores
between min
and max
in descending order.
If start
and num
are specified, then return a slice
of the range.
withscores
indicates to return the scores along with the values.
The return type is a list of (value, score) pairs
score_cast_func
a callable used to cast the score return value
For more information see https://redis.io/commands/zrevrangebyscore
azrevrank
async
azrevrank(
name: kvdb.types.generic.KeyT,
value: redis.typing.EncodableT,
withscore: bool = False,
) -> redis.commands.core.ResponseT
Returns a 0-based value indicating the descending rank of
value
in sorted set name
.
The optional withscore
argument supplements the command's
reply with the score of the element returned.
For more information see https://redis.io/commands/zrevrank
azscan
async
azscan(
name: kvdb.types.generic.KeyT,
cursor: int = 0,
match: typing.Union[redis.typing.PatternT, None] = None,
count: typing.Union[int, None] = None,
score_cast_func: typing.Union[
kvdb.components.session.KVDBSession.type,
typing.Callable,
] = ...,
) -> redis.commands.core.ResponseT
Incrementally return lists of elements in a sorted set. Also return a cursor indicating the scan position.
match
allows for filtering the keys by pattern
count
allows for hint the minimum number of returns
score_cast_func
a callable used to cast the score return value
For more information see https://redis.io/commands/zscan
azscan_iter
async
azscan_iter(
name: kvdb.types.generic.KeyT,
match: typing.Union[redis.typing.PatternT, None] = None,
count: typing.Union[int, None] = None,
score_cast_func: typing.Union[
kvdb.components.session.KVDBSession.type,
typing.Callable,
] = ...,
) -> typing.AsyncIterator
Make an iterator using the ZSCAN command so that the client doesn't need to remember the cursor position.
match
allows for filtering the keys by pattern
count
allows for hint the minimum number of returns
score_cast_func
a callable used to cast the score return value
azscore
async
azscore(
name: kvdb.types.generic.KeyT,
value: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Return the score of element value
in sorted set name
For more information see https://redis.io/commands/zscore
azunion
async
azunion(
keys: typing.Union[
typing.Sequence[kvdb.types.generic.KeyT],
typing.Mapping[redis.typing.AnyKeyT, float],
],
aggregate: typing.Union[str, None] = None,
withscores: bool = False,
) -> redis.commands.core.ResponseT
Return the union of multiple sorted sets specified by keys
.
keys
can be provided as dictionary of keys and their weights.
Scores will be aggregated based on the aggregate
, or SUM if
none is provided.
For more information see https://redis.io/commands/zunion
azunionstore
async
azunionstore(
dest: kvdb.types.generic.KeyT,
keys: typing.Union[
typing.Sequence[kvdb.types.generic.KeyT],
typing.Mapping[redis.typing.AnyKeyT, float],
],
aggregate: typing.Union[str, None] = None,
) -> redis.commands.core.ResponseT
Union multiple sorted sets specified by keys
into
a new sorted set, dest
. Scores in the destination will be
aggregated based on the aggregate
, or SUM if none is provided.
For more information see https://redis.io/commands/zunionstore
bgrewriteaof
Tell the Redis server to rewrite the AOF file from data in memory.
For more information see https://redis.io/commands/bgrewriteaof
bgsave
Tell the Redis server to save its data to disk. Unlike save(), this method is asynchronous and returns immediately.
For more information see https://redis.io/commands/bgsave
bitcount
bitcount(
key: kvdb.types.generic.KeyT,
start: typing.Union[int, None] = None,
end: typing.Union[int, None] = None,
mode: typing.Optional[str] = None,
) -> redis.commands.core.ResponseT
Returns the count of set bits in the value of key
. Optional
start
and end
parameters indicate which bytes to consider
For more information see https://redis.io/commands/bitcount
bitfield
bitfield(
key: kvdb.types.generic.KeyT,
default_overflow: typing.Union[str, None] = None,
) -> redis.commands.core.BitFieldOperation
Return a BitFieldOperation instance to conveniently construct one or
more bitfield operations on key
.
For more information see https://redis.io/commands/bitfield
bitfield_ro
bitfield_ro(
key: kvdb.types.generic.KeyT,
encoding: str,
offset: redis.typing.BitfieldOffsetT,
items: typing.Optional[list] = None,
) -> redis.commands.core.ResponseT
Return an array of the specified bitfield values
where the first value is found using encoding
and offset
parameters and remaining values are result of corresponding
encoding/offset pairs in optional list items
Read-only variant of the BITFIELD command.
For more information see https://redis.io/commands/bitfield_ro
bitop
bitop(
operation: str,
dest: kvdb.types.generic.KeyT,
*keys: kvdb.types.generic.KeyT
) -> redis.commands.core.ResponseT
Perform a bitwise operation using operation
between keys
and
store the result in dest
.
For more information see https://redis.io/commands/bitop
bitpos
bitpos(
key: kvdb.types.generic.KeyT,
bit: int,
start: typing.Union[int, None] = None,
end: typing.Union[int, None] = None,
mode: typing.Optional[str] = None,
) -> redis.commands.core.ResponseT
Return the position of the first bit set to 1 or 0 in a string.
start
and end
defines 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 see https://redis.io/commands/bitpos
blmove
blmove(
first_list: str,
second_list: str,
timeout: int,
src: str = "LEFT",
dest: str = "RIGHT",
) -> redis.commands.core.ResponseT
Blocking version of lmove.
For more information see https://redis.io/commands/blmove
blmpop
blmpop(
timeout: float,
numkeys: int,
*args: typing.List[str],
direction: str,
count: typing.Optional[int] = 1
) -> typing.Optional[list]
Pop count
values (default 1) from first non-empty in the list
of provided key names.
When all lists are empty this command blocks the connection until another client pushes to it or until the timeout, timeout of 0 blocks indefinitely
For more information see https://redis.io/commands/blmpop
blpop
blpop(
keys: typing.List, timeout: typing.Optional[int] = 0
) -> typing.Union[typing.Awaitable[list], list]
LPOP a value off of the first non-empty list
named in the keys
list.
If none of the lists in keys
has a value to LPOP, then block
for timeout
seconds, or until a value gets pushed on to one
of the lists.
If timeout is 0, then block indefinitely.
For more information see https://redis.io/commands/blpop
brpop
brpop(
keys: typing.List, timeout: typing.Optional[int] = 0
) -> typing.Union[typing.Awaitable[list], list]
RPOP a value off of the first non-empty list
named in the keys
list.
If none of the lists in keys
has a value to RPOP, then block
for timeout
seconds, or until a value gets pushed on to one
of the lists.
If timeout is 0, then block indefinitely.
For more information see https://redis.io/commands/brpop
brpoplpush
brpoplpush(
src: str, dst: str, timeout: typing.Optional[int] = 0
) -> typing.Union[
typing.Awaitable[typing.Optional[str]],
typing.Optional[str],
]
Pop a value off the tail of src
, push it on the head of dst
and then return it.
This command blocks until a value is in src
or until timeout
seconds elapse, whichever is first. A timeout
value of 0 blocks
forever.
For more information see https://redis.io/commands/brpoplpush
bzmpop
bzmpop(
timeout: float,
numkeys: int,
keys: typing.List[str],
min: typing.Optional[bool] = False,
max: typing.Optional[bool] = False,
count: typing.Optional[int] = 1,
) -> typing.Optional[list]
Pop count
values (default 1) off of the first non-empty sorted set
named in the keys
list.
If none of the sorted sets in keys
has a value to pop,
then block for timeout
seconds, or until a member gets added
to one of the sorted sets.
If timeout is 0, then block indefinitely.
For more information see https://redis.io/commands/bzmpop
bzpopmax
bzpopmax(
keys: redis.typing.KeysT,
timeout: redis.typing.TimeoutSecT = 0,
) -> redis.commands.core.ResponseT
ZPOPMAX a value off of the first non-empty sorted set
named in the keys
list.
If none of the sorted sets in keys
has a value to ZPOPMAX,
then block for timeout
seconds, or until a member gets added
to one of the sorted sets.
If timeout is 0, then block indefinitely.
For more information see https://redis.io/commands/bzpopmax
bzpopmin
bzpopmin(
keys: redis.typing.KeysT,
timeout: redis.typing.TimeoutSecT = 0,
) -> redis.commands.core.ResponseT
ZPOPMIN a value off of the first non-empty sorted set
named in the keys
list.
If none of the sorted sets in keys
has a value to ZPOPMIN,
then block for timeout
seconds, or until a member gets added
to one of the sorted sets.
If timeout is 0, then block indefinitely.
For more information see https://redis.io/commands/bzpopmin
client_getname
Returns the current connection name
For more information see https://redis.io/commands/client-getname
client_getredir
Returns the ID (an integer) of the client to whom we are redirecting tracking notifications.
see: https://redis.io/commands/client-getredir
client_id
Returns the current connection id
For more information see https://redis.io/commands/client-id
client_info
Returns information and statistics about the current client connection.
For more information see https://redis.io/commands/client-info
client_kill
Disconnects the client at address
(ip:port)
For more information see https://redis.io/commands/client-kill
client_kill_filter
client_kill_filter(
_id: typing.Union[str, None] = None,
_type: typing.Union[str, None] = None,
addr: typing.Union[str, None] = None,
skipme: typing.Union[bool, None] = None,
laddr: typing.Union[bool, None] = None,
user: str = None,
**kwargs
) -> redis.commands.core.ResponseT
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
client_list(
_type: typing.Union[str, None] = None,
client_id: typing.List[redis.typing.EncodableT] = [],
**kwargs
) -> redis.commands.core.ResponseT
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) :param client_id: optional. a list of client ids
For more information see https://redis.io/commands/client-list
client_no_evict
Sets the client eviction mode for the current connection.
For more information see https://redis.io/commands/client-no-evict
client_no_touch
The command controls whether commands sent by the client will alter
the LRU/LFU of the keys they access.
When turned on, the current client will not change LFU/LRU stats,
unless it sends the TOUCH command.
For more information see https://redis.io/commands/client-no-touch
client_pause
Suspend all the Redis clients for the specified amount of time.
For more information see https://redis.io/commands/client-pause
:param timeout: milliseconds to pause clients :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
client_reply(
reply: typing.Union[
typing.Literal["ON"],
typing.Literal["OFF"],
typing.Literal["SKIP"],
],
**kwargs
) -> redis.commands.core.ResponseT
Enable and disable redis server replies.
reply
Must 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.
See https://redis.io/commands/client-reply
client_setinfo
Sets the current connection library name or version For mor information see https://redis.io/commands/client-setinfo
client_setname
Sets the current connection name
For more information see https://redis.io/commands/client-setname
.. note:: This method sets client name only for current connection.
If you want to set a common name for all connections managed
by this client, use client_name
constructor argument.
client_tracking
client_tracking(
on: bool = True,
clientid: typing.Union[int, None] = None,
prefix: typing.Sequence[kvdb.types.generic.KeyT] = [],
bcast: bool = False,
optin: bool = False,
optout: bool = False,
noloop: bool = False,
**kwargs
) -> redis.commands.core.ResponseT
Enables the tracking feature of the Redis server, that is used for server assisted client side caching.
on
indicate for tracking on or tracking off. The dafualt is on.
clientid
send invalidation messages to the connection with
the specified ID.
bcast
enable tracking in broadcasting mode. In this mode
invalidation messages are reported for all the prefixes
specified, regardless of the keys requested by the connection.
optin
when broadcasting is NOT active, normally don't track
keys in read only commands, unless they are called immediately
after a CLIENT CACHING yes command.
optout
when broadcasting is NOT active, normally track keys in
read only commands, unless they are called immediately after a
CLIENT CACHING no command.
noloop
don't send notifications about keys modified by this
connection itself.
prefix
for broadcasting, register a given key prefix, so that
notifications will be provided only for keys starting with this string.
See https://redis.io/commands/client-tracking
client_tracking_off
client_tracking_off(
clientid: typing.Union[int, None] = None,
prefix: typing.Sequence[kvdb.types.generic.KeyT] = [],
bcast: bool = False,
optin: bool = False,
optout: bool = False,
noloop: bool = False,
) -> redis.commands.core.ResponseT
Turn off the tracking mode. For more information about the options look at client_tracking func.
See https://redis.io/commands/client-tracking
client_tracking_on
client_tracking_on(
clientid: typing.Union[int, None] = None,
prefix: typing.Sequence[kvdb.types.generic.KeyT] = [],
bcast: bool = False,
optin: bool = False,
optout: bool = False,
noloop: bool = False,
) -> redis.commands.core.ResponseT
Turn on the tracking mode. For more information about the options look at client_tracking func.
See https://redis.io/commands/client-tracking
client_trackinginfo
Returns the information about the current client connection's use of the server assisted client side cache.
See https://redis.io/commands/client-trackinginfo
client_unblock
Unblocks a connection by its client id.
If error
is True, unblocks the client with a special error message.
If error
is False (default), the client is unblocked using the
regular timeout mechanism.
For more information see https://redis.io/commands/client-unblock
client_unpause
Unpause all redis clients
For more information see https://redis.io/commands/client-unpause
close
Close the session
Source code in kvdb/components/session.py
close_locks
close_locks(
names: typing.Optional[
typing.Union[typing.List[str], str]
] = None,
force: typing.Optional[bool] = False,
raise_errors: typing.Optional[bool] = False,
)
Closes the locks that are currently managed by the session
Source code in kvdb/components/session.py
command_docs
This function throws a NotImplementedError since it is intentionally not supported.
command_getkeysandflags
command_getkeysandflags(
*args: typing.List[str],
) -> typing.List[typing.Union[str, typing.List[str]]]
Returns array of keys from a full Redis command and their usage flags.
For more information see https://redis.io/commands/command-getkeysandflags
command_list
command_list(
module: typing.Optional[str] = None,
category: typing.Optional[str] = None,
pattern: typing.Optional[str] = None,
) -> redis.commands.core.ResponseT
Return an array of the server's command names.
You can use one of the following filters:
module
: get the commands that belong to the module
category
: get the commands in the ACL category
pattern
: get the commands that match the given pattern
For more information see https://redis.io/commands/command-list/
config_get
config_get(
pattern: redis.typing.PatternT = "*",
*args: typing.List[redis.typing.PatternT],
**kwargs
) -> redis.commands.core.ResponseT
Return a dictionary of configuration based on the pattern
For more information see https://redis.io/commands/config-get
config_resetstat
Reset runtime statistics
For more information see https://redis.io/commands/config-resetstat
config_rewrite
Rewrite config file with the minimal change to reflect running config.
For more information see https://redis.io/commands/config-rewrite
config_set
config_set(
name: kvdb.types.generic.KeyT,
value: redis.typing.EncodableT,
*args: typing.List[
typing.Union[
kvdb.types.generic.KeyT, redis.typing.EncodableT
]
],
**kwargs
) -> redis.commands.core.ResponseT
Set config item name
with value
For more information see https://redis.io/commands/config-set
copy
copy(
source: str,
destination: str,
destination_db: typing.Union[str, None] = None,
replace: bool = False,
) -> redis.commands.core.ResponseT
Copy the value stored in the source
key to the destination
key.
destination_db
an alternative destination database. By default,
the destination
key is created in the source Redis database.
replace
whether the destination
key should be removed before
copying the value to it. By default, the value is not copied if
the destination
key already exists.
For more information see https://redis.io/commands/copy
create_persistence
create_persistence(
name: typing.Optional[str] = None,
base_key: typing.Optional[str] = None,
**kwargs
) -> lazyops.libs.persistence.PersistentDict
Create a new persistence instance
Source code in kvdb/components/session.py
dbsize
Returns the number of keys in the current database
For more information see https://redis.io/commands/dbsize
debug_object
Returns version specific meta information about a given key
For more information see https://redis.io/commands/debug-object
decrby
Decrements the value of key
by amount
. If no key exists,
the value will be initialized as 0 - amount
For more information see https://redis.io/commands/decrby
delete
Delete one or more keys specified by names
delitem
disable_serialization
Disable Serialization in the Encoder
Source code in kvdb/components/session.py
dump
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 see https://redis.io/commands/dump
echo
Echo the string back from the server
For more information see https://redis.io/commands/echo
enable_serialization
enable_serialization(
serializer: typing.Optional[
kvdb.io.serializers.SerializerT
] = None,
decode_responses: typing.Optional[bool] = None,
)
Enable Serialization in the Encoder
Source code in kvdb/components/session.py
eval
Execute the Lua script
, specifying the numkeys
the script
will touch and the key names and argument values in keys_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 see https://redis.io/commands/eval
eval_ro
eval_ro(
script: str, numkeys: int, *keys_and_args: list
) -> typing.Union[typing.Awaitable[str], str]
The read-only variant of the EVAL command
Execute the read-only Lua script
specifying the numkeys
the script
will touch and the key names and argument values in keys_and_args
.
Returns the result of the script.
For more information see https://redis.io/commands/eval_ro
evalsha
Use the sha
to execute a Lua script already registered via EVAL
or SCRIPT LOAD. Specify the numkeys
the script will touch and the
key names and argument values in keys_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 see https://redis.io/commands/evalsha
evalsha_ro
evalsha_ro(
sha: str, numkeys: int, *keys_and_args: list
) -> typing.Union[typing.Awaitable[str], str]
The read-only variant of the EVALSHA command
Use the sha
to execute a read-only Lua script already registered via EVAL
or SCRIPT LOAD. Specify the numkeys
the script will touch and the
key names and argument values in keys_and_args
. Returns the result
of the script.
For more information see https://redis.io/commands/evalsha_ro
execute_command
exists
Returns the number of names
that exist
For more information see https://redis.io/commands/exists
expire
expire(
name: kvdb.types.generic.KeyT,
time: kvdb.types.generic.ExpiryT,
nx: bool = False,
xx: bool = False,
gt: bool = False,
lt: bool = False,
) -> redis.commands.core.ResponseT
Set an expire flag on key name
for time
seconds with given
option
. time
can be represented by an integer or a Python timedelta
object.
For more information see https://redis.io/commands/expire
expireat
expireat(
name: kvdb.types.generic.KeyT,
when: redis.typing.AbsExpiryT,
nx: bool = False,
xx: bool = False,
gt: bool = False,
lt: bool = False,
) -> redis.commands.core.ResponseT
Set an expire flag on key name
with given option
. when
can be represented as an integer indicating unix time or a Python
datetime object.
For more information see https://redis.io/commands/expireat
expiretime
Returns the absolute Unix timestamp (since January 1, 1970) in seconds at which the given key will expire.
For more information see https://redis.io/commands/expiretime
failover
This function throws a NotImplementedError since it is intentionally not supported.
fcall
fcall(
function,
numkeys: int,
*keys_and_args: typing.Optional[typing.List]
) -> typing.Union[typing.Awaitable[str], str]
Invoke a function.
For more information see https://redis.io/commands/fcall
fcall_ro
fcall_ro(
function,
numkeys: int,
*keys_and_args: typing.Optional[typing.List]
) -> typing.Union[typing.Awaitable[str], str]
This is a read-only variant of the FCALL command that cannot execute commands that modify data.
For more information see https://redis.io/commands/fcal_ro
flushall
Delete all keys in all databases on the current host.
asynchronous
indicates whether the operation is
executed asynchronously by the server.
For more information see https://redis.io/commands/flushall
flushdb
Delete all keys in the current database.
asynchronous
indicates whether the operation is
executed asynchronously by the server.
For more information see https://redis.io/commands/flushdb
function_delete
Delete the library called library
and all its functions.
For more information see https://redis.io/commands/function-delete
function_dump
Return the serialized payload of loaded libraries.
For more information see https://redis.io/commands/function-dump
function_flush
Deletes all the libraries.
For more information see https://redis.io/commands/function-flush
function_kill
Kill a function that is currently executing.
For more information see https://redis.io/commands/function-kill
function_list
function_list(
library: typing.Optional[str] = "*",
withcode: typing.Optional[bool] = False,
) -> typing.Union[
typing.Awaitable[typing.List], typing.List
]
Return information about the functions and libraries. :param library: pecify a pattern for matching library names :param withcode: cause the server to include the libraries source implementation in the reply
function_load
function_load(
code: str, replace: typing.Optional[bool] = False
) -> typing.Union[typing.Awaitable[str], str]
Load a library to Redis. :param code: the source code (must start with Shebang statement that provides a metadata about the library) :param replace: changes the behavior to overwrite the existing library with the new contents. Return the library name that was loaded.
For more information see https://redis.io/commands/function-load
function_restore
function_restore(
payload: str, policy: typing.Optional[str] = "APPEND"
) -> typing.Union[typing.Awaitable[str], str]
Restore libraries from the serialized payload
.
You can use the optional policy argument to provide a policy
for handling existing libraries.
For more information see https://redis.io/commands/function-restore
function_stats
Return information about the function that's currently running and information about the available execution engines.
For more information see https://redis.io/commands/function-stats
geoadd
geoadd(
name: kvdb.types.generic.KeyT,
values: typing.Sequence[redis.typing.EncodableT],
nx: bool = False,
xx: bool = False,
ch: bool = False,
) -> redis.commands.core.ResponseT
Add the specified geospatial items to the specified key identified
by the name
argument. The Geospatial items are given as ordered
members of the values
argument, each item or place is formed by
the triad longitude, latitude and name.
Note: You can use ZREM to remove elements.
nx
forces ZADD to only create new elements and not to update
scores for elements that already exist.
xx
forces ZADD to only update scores of elements that already
exist. New elements will not be added.
ch
modifies 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 see https://redis.io/commands/geoadd
geodist
geodist(
name: kvdb.types.generic.KeyT,
place1: redis.typing.FieldT,
place2: redis.typing.FieldT,
unit: typing.Union[str, None] = None,
) -> redis.commands.core.ResponseT
Return the distance between place1
and place2
members of the
name
key.
The units must be one of the following : m, km mi, ft. By default
meters are used.
For more information see https://redis.io/commands/geodist
geohash
geohash(
name: kvdb.types.generic.KeyT,
*values: redis.typing.FieldT
) -> redis.commands.core.ResponseT
Return the geo hash string for each item of values
members of
the specified key identified by the name
argument.
For more information see https://redis.io/commands/geohash
geopos
geopos(
name: kvdb.types.generic.KeyT,
*values: redis.typing.FieldT
) -> redis.commands.core.ResponseT
Return the positions of each item of values
as members of
the specified key identified by the name
argument. Each position
is represented by the pairs lon and lat.
For more information see https://redis.io/commands/geopos
georadius
georadius(
name: kvdb.types.generic.KeyT,
longitude: float,
latitude: float,
radius: float,
unit: typing.Union[str, None] = None,
withdist: bool = False,
withcoord: bool = False,
withhash: bool = False,
count: typing.Union[int, None] = None,
sort: typing.Union[str, None] = None,
store: typing.Union[
kvdb.types.generic.KeyT, None
] = None,
store_dist: typing.Union[
kvdb.types.generic.KeyT, None
] = None,
any: bool = False,
) -> redis.commands.core.ResponseT
Return the members of the specified key identified by the
name
argument which are within the borders of the area specified
with the latitude
and longitude
location and the maximum
distance from the center specified by the radius
value.
The units must be one of the following : m, km mi, ft. By default
withdist
indicates to return the distances of each place.
withcoord
indicates to return the latitude and longitude of
each place.
withhash
indicates to return the geohash string of each place.
count
indicates to return the number of elements up to N.
sort
indicates to return the places in a sorted way, ASC for
nearest to fairest and DESC for fairest to nearest.
store
indicates 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_dist
indicates to save the places names in a sorted set
named with a specific key, instead of store
the sorted set
destination score is set with the distance.
For more information see https://redis.io/commands/georadius
georadiusbymember
georadiusbymember(
name: kvdb.types.generic.KeyT,
member: redis.typing.FieldT,
radius: float,
unit: typing.Union[str, None] = None,
withdist: bool = False,
withcoord: bool = False,
withhash: bool = False,
count: typing.Union[int, None] = None,
sort: typing.Union[str, None] = None,
store: typing.Union[
kvdb.types.generic.KeyT, None
] = None,
store_dist: typing.Union[
kvdb.types.generic.KeyT, None
] = None,
any: bool = False,
) -> redis.commands.core.ResponseT
This command is exactly like georadius
with 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 see https://redis.io/commands/georadiusbymember
geosearch
geosearch(
name: kvdb.types.generic.KeyT,
member: typing.Union[redis.typing.FieldT, None] = None,
longitude: typing.Union[float, None] = None,
latitude: typing.Union[float, None] = None,
unit: str = "m",
radius: typing.Union[float, None] = None,
width: typing.Union[float, None] = None,
height: typing.Union[float, None] = None,
sort: typing.Union[str, None] = None,
count: typing.Union[int, None] = None,
any: bool = False,
withcoord: bool = False,
withdist: bool = False,
withhash: bool = False,
) -> redis.commands.core.ResponseT
Return the members of specified key identified by the
name
argument, 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.
member
Use the position of the given existing
member in the sorted set. Can't be given with longitude
and latitude
.
longitude
and latitude
Use the position given by
this coordinates. Can't be given with member
radius
Similar to GEORADIUS, search inside circular
area according the given radius. Can't be given with
height
and width
.
height
and width
Search inside an axis-aligned
rectangle, determined by the given height and width.
Can't be given with radius
unit
must 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.
sort
indicates to return the places in a sorted way,
ASC for nearest to furthest and DESC for furthest to nearest.
count
limit the results to the first count matching items.
any
is set to True, the command will return as soon as
enough matches are found. Can't be provided without count
withdist
indicates to return the distances of each place.
withcoord
indicates to return the latitude and longitude of
each place.
withhash
indicates to return the geohash string of each place.
For more information see https://redis.io/commands/geosearch
geosearchstore
geosearchstore(
dest: kvdb.types.generic.KeyT,
name: kvdb.types.generic.KeyT,
member: typing.Union[redis.typing.FieldT, None] = None,
longitude: typing.Union[float, None] = None,
latitude: typing.Union[float, None] = None,
unit: str = "m",
radius: typing.Union[float, None] = None,
width: typing.Union[float, None] = None,
height: typing.Union[float, None] = None,
sort: typing.Union[str, None] = None,
count: typing.Union[int, None] = None,
any: bool = False,
storedist: bool = False,
) -> redis.commands.core.ResponseT
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.
if store_dist
set 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 see https://redis.io/commands/geosearchstore
get
Return the value at key name
, or None if the key doesn't exist
For more information see https://redis.io/commands/get
get_dictkey
getbit
Returns an integer indicating the value of offset
in name
For more information see https://redis.io/commands/getbit
getdel
Get the value at key name
and 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 see https://redis.io/commands/getdel
getex
getex(
name: kvdb.types.generic.KeyT,
ex: typing.Union[
kvdb.types.generic.ExpiryT, None
] = None,
px: typing.Union[
kvdb.types.generic.ExpiryT, None
] = None,
exat: typing.Union[
redis.typing.AbsExpiryT, None
] = None,
pxat: typing.Union[
redis.typing.AbsExpiryT, None
] = None,
persist: bool = False,
) -> redis.commands.core.ResponseT
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.
ex
sets an expire flag on key name
for ex
seconds.
px
sets an expire flag on key name
for px
milliseconds.
exat
sets an expire flag on key name
for ex
seconds,
specified in unix time.
pxat
sets an expire flag on key name
for ex
milliseconds,
specified in unix time.
persist
remove the time to live associated with name
.
For more information see https://redis.io/commands/getex
getitem
getrange
Returns the substring of the string value stored at key
,
determined by the offsets start
and end
(both are inclusive)
For more information see https://redis.io/commands/getrange
getset
getset(
name: kvdb.types.generic.KeyT,
value: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Sets the value at key name
to value
and returns the old value at key name
atomically.
As per Redis 6.2, GETSET is considered deprecated. Please use SET with GET parameter in new code.
For more information see https://redis.io/commands/getset
hdel
Delete keys
from hash name
For more information see https://redis.io/commands/hdel
hello
This function throws a NotImplementedError since it is intentionally not supported.
hexists
Returns a boolean indicating if key
exists within hash name
For more information see https://redis.io/commands/hexists
hget
hget(name: str, key: str) -> typing.Union[
typing.Awaitable[typing.Optional[str]],
typing.Optional[str],
]
Return the value of key
within the hash name
For more information see https://redis.io/commands/hget
hgetall
Return a Python dict of the hash's name/value pairs
For more information see https://redis.io/commands/hgetall
hincrby
Increment the value of key
in hash name
by amount
For more information see https://redis.io/commands/hincrby
hincrbyfloat
hincrbyfloat(
name: str, key: str, amount: float = 1.0
) -> typing.Union[typing.Awaitable[float], float]
Increment the value of key
in hash name
by floating amount
For more information see https://redis.io/commands/hincrbyfloat
hkeys
Return the list of keys within hash name
For more information see https://redis.io/commands/hkeys
hlen
Return the number of elements in hash name
For more information see https://redis.io/commands/hlen
hmget
hmget(
name: str, keys: typing.List, *args: typing.List
) -> typing.Union[
typing.Awaitable[typing.List], typing.List
]
Returns a list of values ordered identically to keys
For more information see https://redis.io/commands/hmget
hmset
Set key to value within hash name
for each corresponding
key and value from the mapping
dict.
For more information see https://redis.io/commands/hmset
hrandfield
hrandfield(
key: str, count: int = None, withvalues: bool = False
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/hrandfield
hscan
hscan(
name: kvdb.types.generic.KeyT,
cursor: int = 0,
match: typing.Union[redis.typing.PatternT, None] = None,
count: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Incrementally return key/value slices in a hash. Also return a cursor indicating the scan position.
match
allows for filtering the keys by pattern
count
allows for hint the minimum number of returns
For more information see https://redis.io/commands/hscan
hscan_iter
hscan_iter(
name: str,
match: typing.Union[redis.typing.PatternT, None] = None,
count: typing.Union[int, None] = None,
) -> typing.Iterator
Make an iterator using the HSCAN command so that the client doesn't need to remember the cursor position.
match
allows for filtering the keys by pattern
count
allows for hint the minimum number of returns
hset
hset(
name: str,
key: typing.Optional[str] = None,
value: typing.Optional[str] = None,
mapping: typing.Optional[dict] = None,
items: typing.Optional[list] = None,
) -> typing.Union[typing.Awaitable[int], int]
Set key
to value
within hash name
,
mapping
accepts a dict of key/value pairs that will be
added to hash name
.
items
accepts a list of key/value pairs that will be
added to hash name
.
Returns the number of fields that were added.
For more information see https://redis.io/commands/hset
hsetnx
Set key
to value
within hash name
if key
does not
exist. Returns 1 if HSETNX created a field, otherwise 0.
For more information see https://redis.io/commands/hsetnx
hstrlen
Return the number of bytes stored in the value of key
within hash name
For more information see https://redis.io/commands/hstrlen
hvals
Return the list of values within hash name
For more information see https://redis.io/commands/hvals
incrby
Increments the value of key
by amount
. If no key exists,
the value will be initialized as amount
For more information see https://redis.io/commands/incrby
incrbyfloat
Increments the value at key name
by floating amount
.
If no key exists, the value will be initialized as amount
For more information see https://redis.io/commands/incrbyfloat
info
info(
section: typing.Union[str, None] = None,
*args: typing.List[str],
**kwargs
) -> redis.commands.core.ResponseT
Returns a dictionary containing information about the Redis server
The section
option can be used to select a specific section
of information
The section option is not supported by older versions of Redis Server, and will generate ResponseError
For more information see https://redis.io/commands/info
init_cache_config
Initializes the cache config
Source code in kvdb/components/session.py
init_encoder
init_encoder(
encoder: typing.Optional[
kvdb.io.encoder.Encoder
] = None,
**kwargs: typing.Any
) -> None
Initializes the encoder
Source code in kvdb/components/session.py
init_serializer
init_serializer(
serializer: typing.Optional[
typing.Union[kvdb.io.serializers.SerializerT, str]
] = None,
**kwargs: typing.Any
) -> None
Initializes the serializer
Source code in kvdb/components/session.py
init_state
Initializes the session state
Source code in kvdb/components/session.py
initialize_class_functions
classmethod
Initializes the class methods and sets them based on both the async and sync methods
Source code in kvdb/components/session.py
715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 |
|
keys
Returns a list of keys matching pattern
For more information see https://redis.io/commands/keys
lastsave
Return a Python datetime object representing the last time the Redis database was saved to disk
For more information see https://redis.io/commands/lastsave
latency_doctor
Raise a NotImplementedError, as the client will not support LATENCY DOCTOR. This funcion is best used within the redis-cli.
For more information see https://redis.io/commands/latency-doctor
latency_graph
Raise a NotImplementedError, as the client will not support LATENCY GRAPH. This funcion is best used within the redis-cli.
For more information see https://redis.io/commands/latency-graph.
latency_histogram
This function throws a NotImplementedError since it is intentionally not supported.
latency_history
Returns the raw data of the event
's latency spikes time series.
For more information see https://redis.io/commands/latency-history
latency_latest
Reports the latest latency events logged.
For more information see https://redis.io/commands/latency-latest
latency_reset
Resets the latency spikes time series of all, or only some, events.
For more information see https://redis.io/commands/latency-reset
lcs
lcs(
key1: str,
key2: str,
len: typing.Optional[bool] = False,
idx: typing.Optional[bool] = False,
minmatchlen: typing.Optional[int] = 0,
withmatchlen: typing.Optional[bool] = False,
) -> typing.Union[str, int, list]
Find the longest common subsequence between key1
and key2
.
If len
is true the length of the match will will be returned.
If idx
is true the match position in each strings will be returned.
minmatchlen
restrict the list of matches to the ones of
the given minmatchlen
.
If withmatchlen
the length of the match also will be returned.
For more information see https://redis.io/commands/lcs
lindex
lindex(name: str, index: int) -> typing.Union[
typing.Awaitable[typing.Optional[str]],
typing.Optional[str],
]
Return the item from list name
at position index
Negative indexes are supported and will return an item at the end of the list
For more information see https://redis.io/commands/lindex
linsert
linsert(
name: str, where: str, refvalue: str, value: str
) -> typing.Union[typing.Awaitable[int], int]
Insert value
in list name
either immediately before or after
[where
] refvalue
Returns the new length of the list on success or -1 if refvalue
is not in the list.
For more information see https://redis.io/commands/linsert
llen
Return the length of the list name
For more information see https://redis.io/commands/llen
lmove
lmove(
first_list: str,
second_list: str,
src: str = "LEFT",
dest: str = "RIGHT",
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/lmove
lmpop
lmpop(
num_keys: int,
*args: typing.List[str],
direction: str,
count: typing.Optional[int] = 1
) -> typing.Union[typing.Awaitable[list], list]
Pop count
values (default 1) first non-empty list key from the list
of args provided key names.
For more information see https://redis.io/commands/lmpop
lock
lock(
name: str,
timeout: typing.Optional[
kvdb.types.generic.Number
] = None,
sleep: typing.Optional[kvdb.types.generic.Number] = 0.1,
blocking: typing.Optional[bool] = True,
blocking_timeout: typing.Optional[
kvdb.types.generic.Number
] = None,
thread_local: typing.Optional[bool] = True,
**kwargs
) -> kvdb.components.lock.Lock
Create a new Lock instance named name
using the Redis client
supplied by keydb
.
timeout
indicates a maximum life for the lock in seconds.
By default, it will remain locked until release() is called.
timeout
can be specified as a float or integer, both representing
the number of seconds to wait.
sleep
indicates the amount of time to sleep in seconds per loop
iteration when the lock is in blocking mode and another client is
currently holding the lock.
blocking
indicates whether calling acquire
should block until
the lock has been acquired or to fail immediately, causing acquire
to return False and the lock not being acquired. Defaults to True.
Note this value can be overridden by passing a blocking
argument to acquire
.
blocking_timeout
indicates the maximum amount of time in seconds to
spend trying to acquire the lock. A value of None
indicates
continue trying forever. blocking_timeout
can be specified as a
float or integer, both representing the number of seconds to wait.
thread_local
indicates whether the lock token is placed in
thread-local storage. By default, the token is placed in thread local
storage so that a thread only sees its token, not a token set by
another thread.
Source code in kvdb/components/session.py
lolwut
Get the Redis version and a piece of generative computer art
See: https://redis.io/commands/lolwut
lpop
lpop(
name: str, count: typing.Optional[int] = None
) -> typing.Union[
typing.Awaitable[typing.Union[str, typing.List, None]],
typing.Union[str, typing.List, 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 count
argument, the reply
will consist of up to count elements, depending on the list's length.
For more information see https://redis.io/commands/lpop
lpos
lpos(
name: str,
value: str,
rank: typing.Optional[int] = None,
count: typing.Optional[int] = None,
maxlen: typing.Optional[int] = None,
) -> typing.Union[str, typing.List, None]
Get position of value
within the list name
If specified, rank
indicates the "rank" of the first element to
return in case there are multiple copies of value
in the list.
By default, LPOS returns the position of the first occurrence of
value
in the list. When rank
2, LPOS returns the position of
the second value
in the list. If rank
is negative, LPOS
searches the list in reverse. For example, -1 would return the
position of the last occurrence of value
and -2 would return the
position of the next to last occurrence of value
.
If specified, count
indicates that LPOS should return a list of
up to count
positions. A count
of 2 would return a list of
up to 2 positions. A count
of 0 returns a list of all positions
matching value
. When count
is specified and but value
does not exist in the list, an empty list is returned.
If specified, maxlen
indicates the maximum number of list
elements to scan. A maxlen
of 1000 will only return the
position(s) of items within the first 1000 entries in the list.
A maxlen
of 0 (the default) will scan the entire list.
For more information see https://redis.io/commands/lpos
lpush
Push values
onto the head of the list name
For more information see https://redis.io/commands/lpush
lpushx
Push value
onto the head of the list name
if name
exists
For more information see https://redis.io/commands/lpushx
lrange
Return a slice of the list name
between
position start
and end
start
and end
can be negative numbers just like
Python slicing notation
For more information see https://redis.io/commands/lrange
lrem
Remove the first count
occurrences of elements equal to value
from the list stored at name
.
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 see https://redis.io/commands/lrem
lset
Set element at index
of list name
to value
For more information see https://redis.io/commands/lset
ltrim
Trim the list name
, removing all values not within the slice
between start
and end
start
and end
can be negative numbers just like
Python slicing notation
For more information see https://redis.io/commands/ltrim
memory_malloc_stats
Return an internal statistics report from the memory allocator.
See: https://redis.io/commands/memory-malloc-stats
memory_purge
Attempts to purge dirty pages for reclamation by allocator
For more information see https://redis.io/commands/memory-purge
memory_stats
Return a dictionary of memory stats
For more information see https://redis.io/commands/memory-stats
memory_usage
memory_usage(
key: kvdb.types.generic.KeyT,
samples: typing.Union[int, None] = None,
**kwargs
) -> redis.commands.core.ResponseT
Return the total memory usage for key, its value and associated administrative overheads.
For nested data structures, samples
is the number of elements to
sample. If left unspecified, the server's default is 5. Use 0 to sample
all elements.
For more information see https://redis.io/commands/memory-usage
mget
Returns a list of values ordered identically to keys
For more information see https://redis.io/commands/mget
migrate
migrate(
host: str,
port: int,
keys: redis.typing.KeysT,
destination_db: int,
timeout: int,
copy: bool = False,
replace: bool = False,
auth: typing.Union[str, None] = None,
**kwargs
) -> redis.commands.core.ResponseT
Migrate 1 or more keys from the current Redis server to a different
server specified by the host
, port
and destination_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 copy
is True, the specified keys
are NOT deleted from
the source server.
If replace
is True, this operation will overwrite the keys
on the destination server if they exist.
If auth
is specified, authenticate to the destination server with
the password provided.
For more information see https://redis.io/commands/migrate
module_list
Returns a list of dictionaries containing the name and version of all loaded modules.
For more information see https://redis.io/commands/module-list
module_load
Loads the module from path
.
Passes all *args
to the module, during loading.
Raises ModuleError
if a module is not found at path
.
For more information see https://redis.io/commands/module-load
module_loadex
module_loadex(
path: str,
options: typing.Optional[typing.List[str]] = None,
args: typing.Optional[typing.List[str]] = None,
) -> redis.commands.core.ResponseT
Loads a module from a dynamic library at runtime with configuration directives.
For more information see https://redis.io/commands/module-loadex
module_unload
Unloads the module name
.
Raises ModuleError
if name
is not in loaded modules.
For more information see https://redis.io/commands/module-unload
move
Moves the key name
to a different Redis database db
For more information see https://redis.io/commands/move
mset
mset(
mapping: typing.Mapping[
redis.typing.AnyKeyT, redis.typing.EncodableT
]
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/mset
msetnx
msetnx(
mapping: typing.Mapping[
redis.typing.AnyKeyT, redis.typing.EncodableT
]
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/msetnx
object
Return the encoding, idletime, or refcount about the key
overflow
Update the overflow algorithm of successive INCRBY operations
:param overflow: Overflow algorithm, one of WRAP, SAT, FAIL. See the
Redis docs for descriptions of these algorithmsself.
:returns: a :py:class:BitFieldOperation
instance.
persist
Removes an expiration on name
For more information see https://redis.io/commands/persist
pexpire
pexpire(
name: kvdb.types.generic.KeyT,
time: kvdb.types.generic.ExpiryT,
nx: bool = False,
xx: bool = False,
gt: bool = False,
lt: bool = False,
) -> redis.commands.core.ResponseT
Set an expire flag on key name
for time
milliseconds
with given option
. time
can be represented by an
integer or a Python timedelta object.
For more information see https://redis.io/commands/pexpire
pexpireat
pexpireat(
name: kvdb.types.generic.KeyT,
when: redis.typing.AbsExpiryT,
nx: bool = False,
xx: bool = False,
gt: bool = False,
lt: bool = False,
) -> redis.commands.core.ResponseT
Set an expire flag on key name
with given option
. when
can be represented as an integer representing unix time in
milliseconds (unix time * 1000) or a Python datetime object.
For more information see https://redis.io/commands/pexpireat
pexpiretime
Returns the absolute Unix timestamp (since January 1, 1970) in milliseconds at which the given key will expire.
For more information see https://redis.io/commands/pexpiretime
pfadd
pfadd(
name: kvdb.types.generic.KeyT,
*values: redis.typing.FieldT
) -> redis.commands.core.ResponseT
Adds the specified elements to the specified HyperLogLog.
For more information see https://redis.io/commands/pfadd
pfcount
Return the approximated cardinality of the set observed by the HyperLogLog at key(s).
For more information see https://redis.io/commands/pfcount
pfmerge
pfmerge(
dest: kvdb.types.generic.KeyT,
*sources: kvdb.types.generic.KeyT
) -> redis.commands.core.ResponseT
Merge N different HyperLogLogs into a single one.
For more information see https://redis.io/commands/pfmerge
ping
Ping the Redis server
For more information see https://redis.io/commands/ping
pipeline
pipeline(
transaction: typing.Optional[bool] = True,
shard_hint: typing.Optional[str] = None,
retryable: typing.Optional[bool] = None,
**kwargs
) -> kvdb.components.pipeline.PipelineT
Return a new pipeline object that can queue multiple commands for
later execution. transaction
indicates whether all commands
should be executed atomically. Apart from making a group of operations
atomic, pipelines are useful for reducing the back-and-forth overhead
between the client and server.
Source code in kvdb/components/session.py
psetex
psetex(
name: kvdb.types.generic.KeyT,
time_ms: kvdb.types.generic.ExpiryT,
value: redis.typing.EncodableT,
)
Set the value of key name
to value
that expires in time_ms
milliseconds. time_ms
can be represented by an integer or a Python
timedelta object
For more information see https://redis.io/commands/psetex
psync
Initiates a replication stream from the master.
Newer version for sync
.
For more information see https://redis.io/commands/sync
pttl
Returns the number of milliseconds until the key name
will expire
For more information see https://redis.io/commands/pttl
publish
publish(
channel: redis.typing.ChannelT,
message: redis.typing.EncodableT,
**kwargs
) -> redis.commands.core.ResponseT
Publish message
on channel
.
Returns the number of subscribers the message was delivered to.
For more information see https://redis.io/commands/publish
pubsub
Return a Publish/Subscribe object. With this object, you can subscribe to channels and listen for messages that get published to
Source code in kvdb/components/session.py
pubsub_channels
Return a list of channels that have at least one subscriber
For more information see https://redis.io/commands/pubsub-channels
pubsub_numpat
Returns the number of subscriptions to patterns
For more information see https://redis.io/commands/pubsub-numpat
pubsub_numsub
Return a list of (channel, number of subscribers) tuples
for each channel given in *args
For more information see https://redis.io/commands/pubsub-numsub
pubsub_shardchannels
pubsub_shardchannels(
pattern: redis.typing.PatternT = "*", **kwargs
) -> redis.commands.core.ResponseT
Return a list of shard_channels that have at least one subscriber
For more information see https://redis.io/commands/pubsub-shardchannels
pubsub_shardnumsub
Return a list of (shard_channel, number of subscribers) tuples
for each channel given in *args
For more information see https://redis.io/commands/pubsub-shardnumsub
quit
Ask the server to close the connection.
For more information see https://redis.io/commands/quit
randomkey
Returns the name of a random key
For more information see https://redis.io/commands/randomkey
readonly
Enables read queries for a connection to a Redis Cluster replica node.
For more information see https://redis.io/commands/readonly
readwrite
Disables read queries for a connection to a Redis Cluster slave node.
For more information see https://redis.io/commands/readwrite
register_script
Register a Lua script
specifying the keys
it 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
rename(
src: kvdb.types.generic.KeyT,
dst: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT
Rename key src
to dst
For more information see https://redis.io/commands/rename
renamenx
Rename key src
to dst
if dst
doesn't already exist
For more information see https://redis.io/commands/renamenx
replicaof
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 see https://redis.io/commands/replicaof
restore
restore(
name: kvdb.types.generic.KeyT,
ttl: float,
value: redis.typing.EncodableT,
replace: bool = False,
absttl: bool = False,
idletime: typing.Union[int, None] = None,
frequency: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Create a key using the provided serialized value, previously obtained using DUMP.
replace
allows an existing key on name
to be overridden. If
it's not specified an error is raised on collision.
absttl
if True, specified ttl
should represent an absolute Unix
timestamp in milliseconds in which the key will expire. (Redis 5.0 or
greater).
idletime
Used for eviction, this is the number of seconds the
key must be idle, prior to execution.
frequency
Used for eviction, this is the frequency counter of
the object stored at the key, prior to execution.
For more information see 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 see https://redis.io/commands/role
rpop
rpop(
name: str, count: typing.Optional[int] = None
) -> typing.Union[
typing.Awaitable[typing.Union[str, typing.List, None]],
typing.Union[str, typing.List, 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 count
argument, the reply will
consist of up to count elements, depending on the list's length.
For more information see https://redis.io/commands/rpop
rpoplpush
RPOP a value off of the src
list and atomically LPUSH it
on to the dst
list. Returns the value.
For more information see https://redis.io/commands/rpoplpush
rpush
Push values
onto the tail of the list name
For more information see https://redis.io/commands/rpush
rpushx
Push value
onto the tail of the list name
if name
exists
For more information see https://redis.io/commands/rpushx
sadd
Add value(s)
to set name
For more information see https://redis.io/commands/sadd
save
Tell the Redis server to save its data to disk, blocking until the save is complete
For more information see https://redis.io/commands/save
scan
scan(
cursor: int = 0,
match: typing.Union[redis.typing.PatternT, None] = None,
count: typing.Union[int, None] = None,
_type: typing.Union[str, None] = None,
**kwargs
) -> redis.commands.core.ResponseT
Incrementally return lists of key names. Also return a cursor indicating the scan position.
match
allows for filtering the keys by pattern
count
provides a hint to Redis about the number of keys to
return per batch.
_type
filters 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 see https://redis.io/commands/scan
scan_iter
scan_iter(
match: typing.Union[redis.typing.PatternT, None] = None,
count: typing.Union[int, None] = None,
_type: typing.Union[str, None] = None,
**kwargs
) -> typing.Iterator
Make an iterator using the SCAN command so that the client doesn't need to remember the cursor position.
match
allows for filtering the keys by pattern
count
provides a hint to Redis about the number of keys to
return per batch.
_type
filters 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
Return the number of elements in set name
For more information see https://redis.io/commands/scard
script_exists
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 see https://redis.io/commands/script-exists
script_flush
script_flush(
sync_type: typing.Union[
typing.Literal["SYNC"], typing.Literal["ASYNC"]
] = None
) -> redis.commands.core.ResponseT
Flush all scripts from the script cache.
sync_type
is by default SYNC (synchronous) but it can also be
ASYNC.
For more information see https://redis.io/commands/script-flush
script_kill
Kill the currently executing Lua script
For more information see https://redis.io/commands/script-kill
script_load
Load a Lua script
into the script cache. Returns the SHA.
For more information see https://redis.io/commands/script-load
sdiff
Return the difference of sets specified by keys
For more information see https://redis.io/commands/sdiff
sdiffstore
sdiffstore(
dest: str, keys: typing.List, *args: typing.List
) -> typing.Union[typing.Awaitable[int], int]
Store the difference of sets specified by keys
into a new
set named dest
. Returns the number of keys in the new set.
For more information see https://redis.io/commands/sdiffstore
select
Select the Redis logical database at index.
See: https://redis.io/commands/select
set
set(
name: kvdb.types.generic.KeyT,
value: redis.typing.EncodableT,
ex: typing.Union[
kvdb.types.generic.ExpiryT, None
] = None,
px: typing.Union[
kvdb.types.generic.ExpiryT, None
] = None,
nx: bool = False,
xx: bool = False,
keepttl: bool = False,
get: bool = False,
exat: typing.Union[
redis.typing.AbsExpiryT, None
] = None,
pxat: typing.Union[
redis.typing.AbsExpiryT, None
] = None,
) -> redis.commands.core.ResponseT
Set the value at key name
to value
ex
sets an expire flag on key name
for ex
seconds.
px
sets an expire flag on key name
for px
milliseconds.
nx
if set to True, set the value at key name
to value
only
if it does not exist.
xx
if set to True, set the value at key name
to value
only
if it already exists.
keepttl
if True, retain the time to live associated with the key.
(Available since Redis 6.0)
get
if True, set the value at key name
to value
and return
the old value stored at key, or None if the key did not exist.
(Available since Redis 6.2)
exat
sets an expire flag on key name
for ex
seconds,
specified in unix time.
pxat
sets an expire flag on key name
for ex
milliseconds,
specified in unix time.
For more information see https://redis.io/commands/set
setbit
Flag the offset
in name
as value
. Returns an integer
indicating the previous value of offset
.
For more information see https://redis.io/commands/setbit
setex
setex(
name: kvdb.types.generic.KeyT,
time: kvdb.types.generic.ExpiryT,
value: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Set the value of key name
to value
that expires in time
seconds. time
can be represented by an integer or a Python
timedelta object.
For more information see https://redis.io/commands/setex
setitem
setitem(
key: kvdb.types.generic.KeyT,
value: typing.Any,
ex: typing.Optional[kvdb.types.generic.ExpiryT] = None,
**kwargs: typing.Any
) -> None
[Dict] Sets the value for the given key
setnx
setnx(
name: kvdb.types.generic.KeyT,
value: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Set the value of key name
to value
if key doesn't exist
For more information see https://redis.io/commands/setnx
setrange
setrange(
name: kvdb.types.generic.KeyT,
offset: int,
value: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Overwrite bytes in the value of name
starting at offset
with
value
. If offset
plus the length of value
exceeds the
length of the original value, the new value will be larger than before.
If offset
exceeds 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 see https://redis.io/commands/setrange
shutdown
shutdown(
save: bool = False,
nosave: bool = False,
now: bool = False,
force: bool = False,
abort: bool = False,
**kwargs
) -> None
Shutdown the Redis server. If Redis has persistence configured,
data will be flushed before shutdown.
It is possible to specify modifiers to alter the behavior of the command:
save
will force a DB saving operation even if no save points are configured.
nosave
will prevent a DB saving operation even if one or more save points
are configured.
now
skips waiting for lagging replicas, i.e. it bypasses the first step in
the shutdown sequence.
force
ignores any errors that would normally prevent the server from exiting
abort
cancels an ongoing shutdown and cannot be combined with other flags.
For more information see https://redis.io/commands/shutdown
sinter
Return the intersection of sets specified by keys
For more information see https://redis.io/commands/sinter
sintercard
sintercard(
numkeys: int, keys: typing.List[str], limit: int = 0
) -> typing.Union[typing.Awaitable[int], int]
Return the cardinality of the intersect of multiple sets specified by `keys
.
When LIMIT provided (defaults to 0 and means unlimited), if the intersection cardinality reaches limit partway through the computation, the algorithm will exit and yield limit as the cardinality
For more information see https://redis.io/commands/sintercard
sinterstore
sinterstore(
dest: str, keys: typing.List, *args: typing.List
) -> typing.Union[typing.Awaitable[int], int]
Store the intersection of sets specified by keys
into a new
set named dest
. Returns the number of keys in the new set.
For more information see https://redis.io/commands/sinterstore
sismember
sismember(name: str, value: str) -> typing.Union[
typing.Awaitable[
typing.Union[typing.Literal[0], typing.Literal[1]]
],
typing.Union[typing.Literal[0], typing.Literal[1]],
]
Return whether value
is a member of set name
:
- 1 if the value is a member of the set.
- 0 if the value is not a member of the set or if key does not exist.
For more information see https://redis.io/commands/sismember
slaveof
slaveof(
host: typing.Union[str, None] = None,
port: typing.Union[int, None] = None,
**kwargs
) -> redis.commands.core.ResponseT
Set the server to be a replicated slave of the instance identified
by the host
and port
. If called without arguments, the
instance is promoted to a master instead.
For more information see https://redis.io/commands/slaveof
slowlog_get
Get the entries from the slowlog. If num
is specified, get the
most recent num
items.
For more information see https://redis.io/commands/slowlog-get
slowlog_len
Get the number of items in the slowlog
For more information see https://redis.io/commands/slowlog-len
slowlog_reset
Remove all items in the slowlog
For more information see https://redis.io/commands/slowlog-reset
smembers
Return all members of the set name
For more information see https://redis.io/commands/smembers
smismember
smismember(
name: str, values: typing.List, *args: typing.List
) -> typing.Union[
typing.Awaitable[
typing.List[
typing.Union[
typing.Literal[0], typing.Literal[1]
]
]
],
typing.List[
typing.Union[typing.Literal[0], typing.Literal[1]]
],
]
Return whether each value in values
is a member of the set name
as a list of int
in the order of values
:
- 1 if the value is a member of the set.
- 0 if the value is not a member of the set or if key does not exist.
For more information see https://redis.io/commands/smismember
smove
Move value
from set src
to set dst
atomically
For more information see https://redis.io/commands/smove
sort
sort(
name: str,
start: typing.Optional[int] = None,
num: typing.Optional[int] = None,
by: typing.Optional[str] = None,
get: typing.Optional[typing.List[str]] = None,
desc: bool = False,
alpha: bool = False,
store: typing.Optional[str] = None,
groups: typing.Optional[bool] = False,
) -> typing.Union[typing.List, int]
Sort and return the list, set or sorted set at name
.
start
and num
allow for paging through the sorted data
by
allows using an external key to weight and sort the items.
Use an "*" to indicate where in the key the item value is located
get
allows 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
desc
allows for reversing the sort
alpha
allows for sorting lexicographically rather than numerically
store
allows for storing the result of the sort into
the key store
groups
if set to True and if get
contains at least two
elements, sort will return a list of tuples, each containing the
values fetched from the arguments to get
.
For more information see https://redis.io/commands/sort
sort_ro
sort_ro(
key: str,
start: typing.Optional[int] = None,
num: typing.Optional[int] = None,
by: typing.Optional[str] = None,
get: typing.Optional[typing.List[str]] = None,
desc: bool = False,
alpha: bool = False,
) -> list
Returns the elements contained in the list, set or sorted set at key. (read-only variant of the SORT command)
start
and num
allow for paging through the sorted data
by
allows using an external key to weight and sort the items.
Use an "*" to indicate where in the key the item value is located
get
allows 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
desc
allows for reversing the sort
alpha
allows for sorting lexicographically rather than numerically
For more information see https://redis.io/commands/sort_ro
spop
Remove and return a random member of set name
For more information see https://redis.io/commands/spop
spublish
spublish(
shard_channel: redis.typing.ChannelT,
message: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Posts a message to the given shard channel. Returns the number of clients that received the message
For more information see https://redis.io/commands/spublish
srandmember
srandmember(
name: str, number: typing.Optional[int] = None
) -> typing.Union[str, typing.List, None]
If number
is None, returns a random member of set name
.
If number
is supplied, returns a list of number
random
members of set name
. Note this is only available when running
Redis 2.6+.
For more information see https://redis.io/commands/srandmember
srem
Remove values
from set name
For more information see https://redis.io/commands/srem
sscan
sscan(
name: kvdb.types.generic.KeyT,
cursor: int = 0,
match: typing.Union[redis.typing.PatternT, None] = None,
count: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Incrementally return lists of elements in a set. Also return a cursor indicating the scan position.
match
allows for filtering the keys by pattern
count
allows for hint the minimum number of returns
For more information see https://redis.io/commands/sscan
sscan_iter
sscan_iter(
name: kvdb.types.generic.KeyT,
match: typing.Union[redis.typing.PatternT, None] = None,
count: typing.Union[int, None] = None,
) -> typing.Iterator
Make an iterator using the SSCAN command so that the client doesn't need to remember the cursor position.
match
allows for filtering the keys by pattern
count
allows for hint the minimum number of returns
stralgo
stralgo(
algo: typing.Literal["LCS"],
value1: kvdb.types.generic.KeyT,
value2: kvdb.types.generic.KeyT,
specific_argument: typing.Union[
typing.Literal["strings"], typing.Literal["keys"]
] = "strings",
len: bool = False,
idx: bool = False,
minmatchlen: typing.Union[int, None] = None,
withmatchlen: bool = False,
**kwargs
) -> redis.commands.core.ResponseT
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.
algo
Right now must be LCS
value1
and value2
Can be two strings or two keys
specific_argument
Specifying if the arguments to the algorithm
will be keys or strings. strings is the default.
len
Returns just the len of the match.
idx
Returns the match positions in each string.
minmatchlen
Restrict the list of matches to the ones of a given
minimal length. Can be provided only when idx
set to True.
withmatchlen
Returns the matches with the len of the match.
Can be provided only when idx
set to True.
For more information see https://redis.io/commands/stralgo
strlen
Return the number of bytes stored in the value of name
For more information see https://redis.io/commands/strlen
substr
Return a substring of the string at key name
. start
and end
are 0-based integers specifying the portion of the string to return.
sunion
sunion(
keys: typing.List, *args: typing.List
) -> typing.Union[
typing.Awaitable[typing.List], typing.List
]
Return the union of sets specified by keys
For more information see https://redis.io/commands/sunion
sunionstore
sunionstore(
dest: str, keys: typing.List, *args: typing.List
) -> typing.Union[typing.Awaitable[int], int]
Store the union of sets specified by keys
into a new
set named dest
. Returns the number of keys in the new set.
For more information see https://redis.io/commands/sunionstore
swapdb
Swap two databases
For more information see https://redis.io/commands/swapdb
sync
Initiates a replication stream from the master.
For more information see https://redis.io/commands/sync
tfcall
tfcall(
lib_name: str,
func_name: str,
keys: redis.typing.KeysT = None,
*args: typing.List
) -> redis.commands.core.ResponseT
Invoke a function.
lib_name
- the library name contains the function.
func_name
- the function name to run.
keys
- the keys that will be touched by the function.
args
- Additional argument to pass to the function.
For more information see https://redis.io/commands/tfcall/
tfcall_async
tfcall_async(
lib_name: str,
func_name: str,
keys: redis.typing.KeysT = None,
*args: typing.List
) -> redis.commands.core.ResponseT
Invoke an async function (coroutine).
lib_name
- the library name contains the function.
func_name
- the function name to run.
keys
- the keys that will be touched by the function.
args
- Additional argument to pass to the function.
For more information see https://redis.io/commands/tfcall/
tfunction_delete
Delete a library from RedisGears.
lib_name
the library name to delete.
For more information see https://redis.io/commands/tfunction-delete/
tfunction_list
tfunction_list(
with_code: bool = False,
verbose: int = 0,
lib_name: typing.Union[str, None] = None,
) -> redis.commands.core.ResponseT
List the functions with additional information about each function.
with_code
Show libraries code.
verbose
output verbosity level, higher number will increase verbosity level
lib_name
specifying a library name (can be used multiple times to show multiple libraries in a single command) # noqa
For more information see https://redis.io/commands/tfunction-list/
tfunction_load
tfunction_load(
lib_code: str,
replace: bool = False,
config: typing.Union[str, None] = None,
) -> redis.commands.core.ResponseT
Load a new library to RedisGears.
lib_code
- the library code.
config
- a string representation of a JSON object
that will be provided to the library on load time,
for more information refer to
https://github.com/RedisGears/RedisGears/blob/master/docs/function_advance_topics.md#library-configuration
replace
- an optional argument, instructs RedisGears to replace the
function if its already exists
For more information see https://redis.io/commands/tfunction-load/
time
Returns the server time as a 2-item tuple of ints: (seconds since epoch, microseconds into this second).
For more information see https://redis.io/commands/time
touch
Alters the last access time of a key(s) *args
. A key is ignored
if it does not exist.
For more information see https://redis.io/commands/touch
ttl
Returns the number of seconds until the key name
will expire
For more information see https://redis.io/commands/ttl
type
Returns the type of key name
For more information see https://redis.io/commands/type
unlink
Unlink one or more keys specified by names
For more information see https://redis.io/commands/unlink
unwatch
Unwatches the value at key name
, or None of the key doesn't exist
For more information see https://redis.io/commands/unwatch
wait
Redis synchronous replication
That returns the number of replicas that processed the query when
we finally have at least num_replicas
, or when the timeout
was
reached.
For more information see https://redis.io/commands/wait
waitaof
waitaof(
num_local: int,
num_replicas: int,
timeout: int,
**kwargs
) -> redis.commands.core.ResponseT
This command blocks the current client until all previous write commands by that client are acknowledged as having been fsynced to the AOF of the local Redis and/or at least the specified number of replicas.
For more information see https://redis.io/commands/waitaof
watch
Watches the values at keys names
, or None if the key doesn't exist
For more information see https://redis.io/commands/watch
xack
xack(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
*ids: redis.typing.StreamIdT
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/xack
xadd
xadd(
name: kvdb.types.generic.KeyT,
fields: typing.Dict[
redis.typing.FieldT, redis.typing.EncodableT
],
id: redis.typing.StreamIdT = "*",
maxlen: typing.Union[int, None] = None,
approximate: bool = True,
nomkstream: bool = False,
minid: typing.Union[
redis.typing.StreamIdT, None
] = None,
limit: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/xadd
xautoclaim
xautoclaim(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
consumername: redis.typing.ConsumerT,
min_idle_time: int,
start_id: redis.typing.StreamIdT = "0-0",
count: typing.Union[int, None] = None,
justid: bool = False,
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/xautoclaim
xclaim
xclaim(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
consumername: redis.typing.ConsumerT,
min_idle_time: int,
message_ids: typing.Union[
typing.List[redis.typing.StreamIdT],
typing.Tuple[redis.typing.StreamIdT],
],
idle: typing.Union[int, None] = None,
time: typing.Union[int, None] = None,
retrycount: typing.Union[int, None] = None,
force: bool = False,
justid: bool = False,
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/xclaim
xdel
xdel(
name: kvdb.types.generic.KeyT,
*ids: redis.typing.StreamIdT
) -> redis.commands.core.ResponseT
Deletes one or more messages from a stream. name: name of the stream. *ids: message ids to delete.
For more information see https://redis.io/commands/xdel
xgroup_create
xgroup_create(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
id: redis.typing.StreamIdT = "$",
mkstream: bool = False,
entries_read: typing.Optional[int] = None,
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/xgroup-create
xgroup_createconsumer
xgroup_createconsumer(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
consumername: redis.typing.ConsumerT,
) -> redis.commands.core.ResponseT
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.
See: https://redis.io/commands/xgroup-createconsumer
xgroup_delconsumer
xgroup_delconsumer(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
consumername: redis.typing.ConsumerT,
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/xgroup-delconsumer
xgroup_destroy
xgroup_destroy(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
) -> redis.commands.core.ResponseT
Destroy a consumer group. name: name of the stream. groupname: name of the consumer group.
For more information see https://redis.io/commands/xgroup-destroy
xgroup_setid
xgroup_setid(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
id: redis.typing.StreamIdT,
entries_read: typing.Optional[int] = None,
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/xgroup-setid
xinfo_consumers
xinfo_consumers(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
) -> redis.commands.core.ResponseT
Returns general information about the consumers in the group. name: name of the stream. groupname: name of the consumer group.
For more information see https://redis.io/commands/xinfo-consumers
xinfo_groups
Returns general information about the consumer groups of the stream. name: name of the stream.
For more information see https://redis.io/commands/xinfo-groups
xinfo_stream
Returns general information about the stream. name: name of the stream. full: optional boolean, false by default. Return full summary
For more information see https://redis.io/commands/xinfo-stream
xlen
Returns the number of elements in a given stream.
For more information see https://redis.io/commands/xlen
xpending
xpending(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
) -> redis.commands.core.ResponseT
Returns information about pending messages of a group. name: name of the stream. groupname: name of the consumer group.
For more information see https://redis.io/commands/xpending
xpending_range
xpending_range(
name: kvdb.types.generic.KeyT,
groupname: redis.typing.GroupT,
min: redis.typing.StreamIdT,
max: redis.typing.StreamIdT,
count: int,
consumername: typing.Union[
redis.typing.ConsumerT, None
] = None,
idle: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
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
xrange(
name: kvdb.types.generic.KeyT,
min: redis.typing.StreamIdT = "-",
max: redis.typing.StreamIdT = "+",
count: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Read stream values within an interval.
name: name of the stream.
first stream ID. defaults to '-',
meaning the earliest available.
last stream ID. defaults to '+',
meaning the latest available.
if set, only return this many items, beginning with the
earliest available.
For more information see https://redis.io/commands/xrange
xread
xread(
streams: typing.Dict[
kvdb.types.generic.KeyT, redis.typing.StreamIdT
],
count: typing.Union[int, None] = None,
block: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Block and monitor multiple streams for new data.
a dict of stream names to stream IDs, where
IDs indicate the last ID already seen.
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 see https://redis.io/commands/xread
xreadgroup
xreadgroup(
groupname: str,
consumername: str,
streams: typing.Dict[
kvdb.types.generic.KeyT, redis.typing.StreamIdT
],
count: typing.Union[int, None] = None,
block: typing.Union[int, None] = None,
noack: bool = False,
) -> redis.commands.core.ResponseT
Read from a stream via a consumer group.
groupname: name of the consumer group.
consumername: name of the requesting consumer.
a dict of stream names to stream IDs, where
IDs indicate the last ID already seen.
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 see https://redis.io/commands/xreadgroup
xrevrange
xrevrange(
name: kvdb.types.generic.KeyT,
max: redis.typing.StreamIdT = "+",
min: redis.typing.StreamIdT = "-",
count: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Read stream values within an interval, in reverse order.
name: name of the stream
first stream ID. defaults to '+',
meaning the latest available.
last stream ID. defaults to '-',
meaning the earliest available.
if set, only return this many items, beginning with the
latest available.
For more information see https://redis.io/commands/xrevrange
xtrim
xtrim(
name: kvdb.types.generic.KeyT,
maxlen: typing.Union[int, None] = None,
approximate: bool = True,
minid: typing.Union[
redis.typing.StreamIdT, None
] = None,
limit: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
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 see https://redis.io/commands/xtrim
zadd
zadd(
name: kvdb.types.generic.KeyT,
mapping: typing.Mapping[
redis.typing.AnyKeyT, redis.typing.EncodableT
],
nx: bool = False,
xx: bool = False,
ch: bool = False,
incr: bool = False,
gt: bool = False,
lt: bool = False,
) -> redis.commands.core.ResponseT
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.
nx
forces ZADD to only create new elements and not to update
scores for elements that already exist.
xx
forces ZADD to only update scores of elements that already
exist. New elements will not be added.
ch
modifies the return value to be the numbers of elements changed.
Changed elements include new elements that were added and elements
whose scores changed.
incr
modifies 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.
LT
Only update existing elements if the new score is less than
the current score. This flag doesn't prevent adding new elements.
GT
Only 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
, and GT
are mutually exclusive options.
See: https://redis.io/commands/ZADD
zcard
Return the number of elements in the sorted set name
For more information see https://redis.io/commands/zcard
zcount
zcount(
name: kvdb.types.generic.KeyT,
min: redis.typing.ZScoreBoundT,
max: redis.typing.ZScoreBoundT,
) -> redis.commands.core.ResponseT
Returns the number of elements in the sorted set at key name
with
a score between min
and max
.
For more information see https://redis.io/commands/zcount
zdiff
Returns the difference between the first and all successive input
sorted sets provided in keys
.
For more information see https://redis.io/commands/zdiff
zdiffstore
zdiffstore(
dest: kvdb.types.generic.KeyT, keys: redis.typing.KeysT
) -> redis.commands.core.ResponseT
Computes the difference between the first and all successive input
sorted sets provided in keys
and stores the result in dest
.
For more information see https://redis.io/commands/zdiffstore
zincrby
zincrby(
name: kvdb.types.generic.KeyT,
amount: float,
value: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Increment the score of value
in sorted set name
by amount
For more information see https://redis.io/commands/zincrby
zinter
zinter(
keys: redis.typing.KeysT,
aggregate: typing.Union[str, None] = None,
withscores: bool = False,
) -> redis.commands.core.ResponseT
Return the intersect of multiple sorted sets specified by keys
.
With the aggregate
option, 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 see https://redis.io/commands/zinter
zintercard
zintercard(
numkeys: int, keys: typing.List[str], limit: int = 0
) -> typing.Union[typing.Awaitable[int], int]
Return the cardinality of the intersect of multiple sorted sets
specified by `keys
.
When LIMIT provided (defaults to 0 and means unlimited), if the intersection
cardinality reaches limit partway through the computation, the algorithm will
exit and yield limit as the cardinality
For more information see https://redis.io/commands/zintercard
zinterstore
zinterstore(
dest: kvdb.types.generic.KeyT,
keys: typing.Union[
typing.Sequence[kvdb.types.generic.KeyT],
typing.Mapping[redis.typing.AnyKeyT, float],
],
aggregate: typing.Union[str, None] = None,
) -> redis.commands.core.ResponseT
Intersect multiple sorted sets specified by keys
into a new
sorted set, dest
. Scores in the destination will be aggregated
based on the aggregate
. 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 see https://redis.io/commands/zinterstore
zlexcount
Return the number of items in the sorted set name
between the
lexicographical range min
and max
.
For more information see https://redis.io/commands/zlexcount
zmpop
zmpop(
num_keys: int,
keys: typing.List[str],
min: typing.Optional[bool] = False,
max: typing.Optional[bool] = False,
count: typing.Optional[int] = 1,
) -> typing.Union[typing.Awaitable[list], list]
Pop count
values (default 1) off of the first non-empty sorted set
named in the keys
list.
For more information see https://redis.io/commands/zmpop
zmscore
Returns the scores associated with the specified members
in the sorted set stored at key.
members
should 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 see https://redis.io/commands/zmscore
zpopmax
zpopmax(
name: kvdb.types.generic.KeyT,
count: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Remove and return up to count
members with the highest scores
from the sorted set name
.
For more information see https://redis.io/commands/zpopmax
zpopmin
zpopmin(
name: kvdb.types.generic.KeyT,
count: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Remove and return up to count
members with the lowest scores
from the sorted set name
.
For more information see https://redis.io/commands/zpopmin
zrandmember
zrandmember(
key: kvdb.types.generic.KeyT,
count: int = None,
withscores: bool = False,
) -> redis.commands.core.ResponseT
Return a random element from the sorted set 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.
withscores
The optional WITHSCORES modifier changes the reply so it
includes the respective scores of the randomly selected elements from
the sorted set.
For more information see https://redis.io/commands/zrandmember
zrange
zrange(
name: kvdb.types.generic.KeyT,
start: int,
end: int,
desc: bool = False,
withscores: bool = False,
score_cast_func: typing.Union[
kvdb.components.session.KVDBSession.type,
typing.Callable,
] = ...,
byscore: bool = False,
bylex: bool = False,
offset: int = None,
num: int = None,
) -> redis.commands.core.ResponseT
Return a range of values from sorted set name
between
start
and end
sorted in ascending order.
start
and end
can be negative, indicating the end of the range.
desc
a boolean indicating whether to sort the results in reversed
order.
withscores
indicates to return the scores along with the values.
The return type is a list of (value, score) pairs.
score_cast_func
a callable used to cast the score return value.
byscore
when set to True, returns the range of elements from the
sorted set having scores equal or between start
and end
.
bylex
when set to True, returns the range of elements from the
sorted set between the start
and end
lexicographical closed
range intervals.
Valid start
and end
must start with ( or [, in order to specify
whether the range interval is exclusive or inclusive, respectively.
offset
and num
are specified, then return a slice of the range.
Can't be provided when using bylex
.
For more information see https://redis.io/commands/zrange
zrangebylex
zrangebylex(
name: kvdb.types.generic.KeyT,
min: redis.typing.EncodableT,
max: redis.typing.EncodableT,
start: typing.Union[int, None] = None,
num: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Return the lexicographical range of values from sorted set name
between min
and max
.
If start
and num
are specified, then return a slice of the
range.
For more information see https://redis.io/commands/zrangebylex
zrangebyscore
zrangebyscore(
name: kvdb.types.generic.KeyT,
min: redis.typing.ZScoreBoundT,
max: redis.typing.ZScoreBoundT,
start: typing.Union[int, None] = None,
num: typing.Union[int, None] = None,
withscores: bool = False,
score_cast_func: typing.Union[
kvdb.components.session.KVDBSession.type,
typing.Callable,
] = ...,
) -> redis.commands.core.ResponseT
Return a range of values from the sorted set name
with scores
between min
and max
.
If start
and num
are specified, then return a slice
of the range.
withscores
indicates to return the scores along with the values.
The return type is a list of (value, score) pairs
`score_cast_func`` a callable used to cast the score return value
For more information see https://redis.io/commands/zrangebyscore
zrangestore
zrangestore(
dest: kvdb.types.generic.KeyT,
name: kvdb.types.generic.KeyT,
start: int,
end: int,
byscore: bool = False,
bylex: bool = False,
desc: bool = False,
offset: typing.Union[int, None] = None,
num: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Stores in dest
the result of a range of values from sorted set
name
between start
and end
sorted in ascending order.
start
and end
can be negative, indicating the end of the range.
byscore
when set to True, returns the range of elements from the
sorted set having scores equal or between start
and end
.
bylex
when set to True, returns the range of elements from the
sorted set between the start
and end
lexicographical closed
range intervals.
Valid start
and end
must start with ( or [, in order to specify
whether the range interval is exclusive or inclusive, respectively.
desc
a boolean indicating whether to sort the results in reversed
order.
offset
and num
are specified, then return a slice of the range.
Can't be provided when using bylex
.
For more information see https://redis.io/commands/zrangestore
zrank
zrank(
name: kvdb.types.generic.KeyT,
value: redis.typing.EncodableT,
withscore: bool = False,
) -> redis.commands.core.ResponseT
Returns a 0-based value indicating the rank of value
in sorted set
name
.
The optional WITHSCORE argument supplements the command's
reply with the score of the element returned.
For more information see https://redis.io/commands/zrank
zrem
zrem(
name: kvdb.types.generic.KeyT,
*values: redis.typing.FieldT
) -> redis.commands.core.ResponseT
Remove member values
from sorted set name
For more information see https://redis.io/commands/zrem
zremrangebylex
zremrangebylex(
name: kvdb.types.generic.KeyT,
min: redis.typing.EncodableT,
max: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Remove all elements in the sorted set name
between the
lexicographical range specified by min
and max
.
Returns the number of elements removed.
For more information see https://redis.io/commands/zremrangebylex
zremrangebyrank
zremrangebyrank(
name: kvdb.types.generic.KeyT, min: int, max: int
) -> redis.commands.core.ResponseT
Remove all elements in the sorted set name
with ranks between
min
and max
. Values are 0-based, ordered from smallest score
to largest. Values can be negative indicating the highest scores.
Returns the number of elements removed
For more information see https://redis.io/commands/zremrangebyrank
zremrangebyscore
zremrangebyscore(
name: kvdb.types.generic.KeyT,
min: redis.typing.ZScoreBoundT,
max: redis.typing.ZScoreBoundT,
) -> redis.commands.core.ResponseT
Remove all elements in the sorted set name
with scores
between min
and max
. Returns the number of elements removed.
For more information see https://redis.io/commands/zremrangebyscore
zrevrange
zrevrange(
name: kvdb.types.generic.KeyT,
start: int,
end: int,
withscores: bool = False,
score_cast_func: typing.Union[
kvdb.components.session.KVDBSession.type,
typing.Callable,
] = ...,
) -> redis.commands.core.ResponseT
Return a range of values from sorted set name
between
start
and end
sorted in descending order.
start
and end
can be negative, indicating the end of the range.
withscores
indicates to return the scores along with the values
The return type is a list of (value, score) pairs
score_cast_func
a callable used to cast the score return value
For more information see https://redis.io/commands/zrevrange
zrevrangebylex
zrevrangebylex(
name: kvdb.types.generic.KeyT,
max: redis.typing.EncodableT,
min: redis.typing.EncodableT,
start: typing.Union[int, None] = None,
num: typing.Union[int, None] = None,
) -> redis.commands.core.ResponseT
Return the reversed lexicographical range of values from sorted set
name
between max
and min
.
If start
and num
are specified, then return a slice of the
range.
For more information see https://redis.io/commands/zrevrangebylex
zrevrangebyscore
zrevrangebyscore(
name: kvdb.types.generic.KeyT,
max: redis.typing.ZScoreBoundT,
min: redis.typing.ZScoreBoundT,
start: typing.Union[int, None] = None,
num: typing.Union[int, None] = None,
withscores: bool = False,
score_cast_func: typing.Union[
kvdb.components.session.KVDBSession.type,
typing.Callable,
] = ...,
)
Return a range of values from the sorted set name
with scores
between min
and max
in descending order.
If start
and num
are specified, then return a slice
of the range.
withscores
indicates to return the scores along with the values.
The return type is a list of (value, score) pairs
score_cast_func
a callable used to cast the score return value
For more information see https://redis.io/commands/zrevrangebyscore
zrevrank
zrevrank(
name: kvdb.types.generic.KeyT,
value: redis.typing.EncodableT,
withscore: bool = False,
) -> redis.commands.core.ResponseT
Returns a 0-based value indicating the descending rank of
value
in sorted set name
.
The optional withscore
argument supplements the command's
reply with the score of the element returned.
For more information see https://redis.io/commands/zrevrank
zscan
zscan(
name: kvdb.types.generic.KeyT,
cursor: int = 0,
match: typing.Union[redis.typing.PatternT, None] = None,
count: typing.Union[int, None] = None,
score_cast_func: typing.Union[
kvdb.components.session.KVDBSession.type,
typing.Callable,
] = ...,
) -> redis.commands.core.ResponseT
Incrementally return lists of elements in a sorted set. Also return a cursor indicating the scan position.
match
allows for filtering the keys by pattern
count
allows for hint the minimum number of returns
score_cast_func
a callable used to cast the score return value
For more information see https://redis.io/commands/zscan
zscan_iter
zscan_iter(
name: kvdb.types.generic.KeyT,
match: typing.Union[redis.typing.PatternT, None] = None,
count: typing.Union[int, None] = None,
score_cast_func: typing.Union[
kvdb.components.session.KVDBSession.type,
typing.Callable,
] = ...,
) -> typing.Iterator
Make an iterator using the ZSCAN command so that the client doesn't need to remember the cursor position.
match
allows for filtering the keys by pattern
count
allows for hint the minimum number of returns
score_cast_func
a callable used to cast the score return value
zscore
zscore(
name: kvdb.types.generic.KeyT,
value: redis.typing.EncodableT,
) -> redis.commands.core.ResponseT
Return the score of element value
in sorted set name
For more information see https://redis.io/commands/zscore
zunion
zunion(
keys: typing.Union[
typing.Sequence[kvdb.types.generic.KeyT],
typing.Mapping[redis.typing.AnyKeyT, float],
],
aggregate: typing.Union[str, None] = None,
withscores: bool = False,
) -> redis.commands.core.ResponseT
Return the union of multiple sorted sets specified by keys
.
keys
can be provided as dictionary of keys and their weights.
Scores will be aggregated based on the aggregate
, or SUM if
none is provided.
For more information see https://redis.io/commands/zunion
zunionstore
zunionstore(
dest: kvdb.types.generic.KeyT,
keys: typing.Union[
typing.Sequence[kvdb.types.generic.KeyT],
typing.Mapping[redis.typing.AnyKeyT, float],
],
aggregate: typing.Union[str, None] = None,
) -> redis.commands.core.ResponseT
Union multiple sorted sets specified by keys
into
a new sorted set, dest
. Scores in the destination will be
aggregated based on the aggregate
, or SUM if none is provided.
For more information see https://redis.io/commands/zunionstore