Skip to content

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
def __init__(
    self,
    name: str,
    url: Union[str, KVDBUrl],
    *,
    pool: SessionPools,
    db_id: Optional[int] = None,
    serializer: Optional[Union['SerializerT', str]] = None,
    encoder: Optional['Encoder'] = None,
    **kwargs: Any,
) -> None:
    """
    Initializes the KVDB Session
    """
    if isinstance(url, str): url = KVDBUrl(url)
    self.name = name
    self.url = url
    self.pool = pool
    if db_id is not None and db_id != self.url.db_id:
        self.url = self.url.with_db_id(db_id)
    self.settings = settings
    self.logger = settings.logger
    self.autologger = settings.autologger
    self.init_serializer(serializer, **kwargs)
    self.init_encoder(encoder, **kwargs)
    self.init_cache_config(**kwargs)
    self.init_state(**kwargs)
    self._version: Optional[str] = None
    self._persistence: Optional['PersistentDict'] = None
    self._persistence_ctx: Dict[str, 'PersistentDict'] = {}
    self._kwargs = kwargs

aclient property

aclient: kvdb.components.client.AsyncKVDB

[Async] The KVDB client

client property

client: kvdb.components.client.KVDB

[Sync] The KVDB client

db_id property

db_id: typing.Optional[int]

Returns the database ID

persistence property

persistence: lazyops.libs.persistence.PersistentDict

Returns the PersistentDict instance that utilizes the session's client

session_serialization_enabled property

session_serialization_enabled: bool

Returns whether session serialization is enabled which is determined by the pool's encoder serialization to be enabled

version property

version: str

Returns the version

__aenter__ async

__aenter__()

Enter the runtime context related to this object.

Source code in kvdb/components/session.py
async def __aenter__(self):
    """
    Enter the runtime context related to this object.
    """
    return self

__aexit__ async

__aexit__(exc_type, exc_val, exc_tb)

Close the session

Source code in kvdb/components/session.py
async def __aexit__(self, exc_type, exc_val, exc_tb):
    """
    Close the session
    """
    await self.aclose()

__contains__

__contains__(key: kvdb.types.generic.KeyT) -> bool

[Dict] Returns whether the key exists

Source code in kvdb/components/session.py
def __contains__(self, key: KeyT) -> bool:
    """
    [Dict] Returns whether the key exists
    """
    return self.persistence.contains(key)

__delitem__

__delitem__(key: kvdb.types.generic.KeyT) -> None

[Dict] Deletes the key

Source code in kvdb/components/session.py
def __delitem__(self, key: KeyT) -> None:
    """
    [Dict] Deletes the key
    """
    if settings.is_in_async_loop():
        return ThreadPooler.create_background_task(self.adelitem, key)
    return self.delitem(key)

__enter__

__enter__()

Enter the runtime context related to this object.

Source code in kvdb/components/session.py
def __enter__(self):
    """
    Enter the runtime context related to this object.
    """
    return self

__exit__

__exit__(
    exc_type: (
        kvdb.components.session.KVDBSession.type[
            BaseException
        ]
        | None
    ),
    exc_val: BaseException | None,
    exc_tb: types.TracebackType | None,
)

On exit, close the session

Source code in kvdb/components/session.py
def __exit__(self, exc_type, exc_val, exc_tb):
    """
    On exit, close the session
    """
    self.close()

__getitem__

__getitem__(
    key: kvdb.types.generic.KeyT,
) -> kvdb.components.session.ReturnT

[Dict] Returns the value for the given key

Source code in kvdb/components/session.py
def __getitem__(self, key: KeyT) -> ResponseT:
    """
    [Dict] Returns the value for the given key
    """
    return self.getitem(key)

__setitem__

__setitem__(
    key: kvdb.types.generic.KeyT, value: typing.Any
) -> None

[Dict] Sets the value for the given key

Source code in kvdb/components/session.py
def __setitem__(self, key: KeyT, value: Any) -> None:
    """
    [Dict] Sets the value for the given key
    """
    if settings.is_in_async_loop():
        return ThreadPooler.create_background_task(
            self.asetitem, key, value,
        )
    return self.setitem(key, value)

aacl_cat async

aacl_cat(
    category: typing.Union[str, None] = None, **kwargs
) -> redis.commands.core.ResponseT

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
if self._persistence is None:
    from .persistence import KVDBStatefulBackend
    persistence_config = self.settings.persistence.model_dump(exclude_none = True)
    persistence_kwargs = self.settings.persistence.extract_kwargs(_prefix = 'persistence_', _exclude_none = True, **self._kwargs)
    if persistence_kwargs: persistence_config.update(persistence_kwargs)
    if 'name' not in persistence_config: persistence_config['name'] = self.name
    self._persistence = KVDBStatefulBackend.as_persistent_dict(
        session = self,
        **persistence_config,
    )

aacl_deluser async

aacl_deluser(
    *username: str, **kwargs
) -> redis.commands.core.ResponseT

Delete the ACL for the specified usernames

For more information see https://redis.io/commands/acl-deluser

Source code in kvdb/components/session.py
    return self.client.execute_command(*args, **options)

async def aexecute_command(self, *args: Any, **options: Any) -> Any:
    """
    Execute a command and return a parsed response
    """

aacl_dryrun async

aacl_dryrun(username, *args, **kwargs)

Simulate the execution of a given command by a given username.

For more information see https://redis.io/commands/acl-dryrun

Source code in kvdb/components/session.py
    return self._persistence

def execute_command(self, *args: Any, **options: Any) -> Any:
    """
    Execute a command and return a parsed response
    """

aacl_genpass async

aacl_genpass(
    bits: typing.Union[int, None] = None, **kwargs
) -> redis.commands.core.ResponseT

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

Source code in kvdb/components/session.py
    return await self.aclient.execute_command(*args, **options)

"""
Component Methods
"""

aacl_getuser async

aacl_getuser(
    username: str, **kwargs
) -> redis.commands.core.ResponseT

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

Source code in kvdb/components/session.py
def create_persistence(
    self,
    name: Optional[str] = None,
    base_key: Optional[str] = None,
    **kwargs,
) -> 'PersistentDict':
    """
    Create a new persistence instance

aacl_help async

aacl_help(**kwargs) -> redis.commands.core.ResponseT

The ACL HELP command returns helpful text describing the different subcommands.

For more information see https://redis.io/commands/acl-help

Source code in kvdb/components/session.py
"""
# name = name or self.name
# if name in self._persistence_ctx:
#     return self._persistence_ctx[name]

from .persistence import KVDBStatefulBackend

aacl_list async

aacl_list(**kwargs) -> redis.commands.core.ResponseT

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
persistence_config = self.settings.persistence.model_dump(exclude_none = True)
persistence_kwargs = self.settings.persistence.extract_kwargs(_prefix = 'persistence_', _exclude_none = True, **self._kwargs)
if persistence_kwargs: persistence_config.update(persistence_kwargs)
if 'name' not in persistence_config: persistence_config['name'] = self.name
if base_key is not None: persistence_config['base_key'] = base_key
persistence_config.update(kwargs)

aacl_load async

aacl_load(**kwargs) -> redis.commands.core.ResponseT

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
    """
    Return a Publish/Subscribe object. With this object, you can
    subscribe to channels and listen for messages that get published to
    """
    if retryable is None: retryable = self.settings.retry.pubsub_enabled
    return self.client.pubsub(retryable = retryable, **kwargs)

def apubsub(
    self, 

aacl_log async

aacl_log(
    count: typing.Union[int, None] = None, **kwargs
) -> redis.commands.core.ResponseT

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
base_key = persistence_config.get('base_key')
if base_key in self._persistence_ctx:
    return self._persistence_ctx[base_key]
p = KVDBStatefulBackend.as_persistent_dict(
    session = self,
    **persistence_config,
)
self._persistence_ctx[base_key] = p

aacl_log_reset async

aacl_log_reset(**kwargs) -> redis.commands.core.ResponseT

Reset ACL logs. :rtype: Boolean.

For more information see https://redis.io/commands/acl-log

Source code in kvdb/components/session.py
    return p

def pubsub(
    self, 
    retryable: Optional[bool] = None,
    **kwargs
) -> PubSubT:

aacl_save async

aacl_save(**kwargs) -> redis.commands.core.ResponseT

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
    retryable: Optional[bool] = None,
    **kwargs
) -> AsyncPubSubT:
    """
    Return a Publish/Subscribe object. With this object, you can
    subscribe to channels and listen for messages that get published to
    """
    if retryable is None: retryable = self.settings.retry.pubsub_enabled
    return self.aclient.pubsub(retryable = retryable, **kwargs)

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
"""
PubSub Utility Methods
"""

def pipeline(
    self, 
    transaction: Optional[bool] = True, 
    shard_hint: Optional[str] = None, 
    retryable: Optional[bool] = None,
    **kwargs
) -> 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.
    """
    if retryable is None: retryable = self.settings.retry.pipeline_enabled
    return self.client.pipeline(transaction = transaction, shard_hint = shard_hint, retryable = retryable)

def apipeline(
    self, 
    transaction: Optional[bool] = True, 
    shard_hint: Optional[str] = None, 
    retryable: Optional[bool] = None,
    **kwargs
) -> 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.
    """
    if retryable is None: retryable = self.settings.retry.pipeline_enabled
    return self.aclient.pipeline(transaction = transaction, shard_hint = shard_hint, retryable = retryable)

def lock(
    self, 
    name: str, 
    timeout: Optional[Number] = None,
    sleep: Optional[Number] = 0.1,
    blocking: Optional[bool] = True,
    blocking_timeout: Optional[Number] = None,
    thread_local: Optional[bool] = True,
    **kwargs,
) -> 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``.

aacl_users async

aacl_users(**kwargs) -> redis.commands.core.ResponseT

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
``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.

aacl_whoami async

aacl_whoami(**kwargs) -> redis.commands.core.ResponseT

Get the username for the current connection

For more information see https://redis.io/commands/acl-whoami

Source code in kvdb/components/session.py
``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. 
"""

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

aauth(
    password: str,
    username: typing.Optional[str] = None,
    **kwargs
)

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

Source code in kvdb/components/session.py
        timeout = timeout, 
        sleep = sleep, 
        blocking = blocking, 
        blocking_timeout = blocking_timeout, 
        thread_local = thread_local
    )
if self.state.lock is None: self.state.lock = self.state.locks[name]

abgrewriteaof async

abgrewriteaof(**kwargs)

Tell the Redis server to rewrite the AOF file from data in memory.

For more information see https://redis.io/commands/bgrewriteaof

Source code in kvdb/components/session.py
    return self.state.locks[name]

def alock(
    self, 
    name: str, 

abgsave async

abgsave(
    schedule: bool = True, **kwargs
) -> redis.commands.core.ResponseT

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

Source code in kvdb/components/session.py
    timeout: Optional[Number] = None,
    sleep: Number = 0.1,
    blocking: bool = True,
    blocking_timeout: Optional[Number] = None,
    thread_local: bool = True,
    **kwargs,
) -> AsyncLock:

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

acl_cat(
    category: typing.Union[str, None] = None, **kwargs
) -> redis.commands.core.ResponseT

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

acl_deluser(
    *username: str, **kwargs
) -> redis.commands.core.ResponseT

Delete the ACL for the specified usernames

For more information see https://redis.io/commands/acl-deluser

acl_dryrun

acl_dryrun(username, *args, **kwargs)

Simulate the execution of a given command by a given username.

For more information see https://redis.io/commands/acl-dryrun

acl_genpass

acl_genpass(
    bits: typing.Union[int, None] = None, **kwargs
) -> redis.commands.core.ResponseT

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

acl_getuser(
    username: str, **kwargs
) -> redis.commands.core.ResponseT

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

acl_help(**kwargs) -> redis.commands.core.ResponseT

The ACL HELP command returns helpful text describing the different subcommands.

For more information see https://redis.io/commands/acl-help

acl_list

acl_list(**kwargs) -> redis.commands.core.ResponseT

Return a list of all ACLs on the server

For more information see https://redis.io/commands/acl-list

acl_load

acl_load(**kwargs) -> redis.commands.core.ResponseT

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

acl_log(
    count: typing.Union[int, None] = None, **kwargs
) -> redis.commands.core.ResponseT

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

acl_log_reset(**kwargs) -> redis.commands.core.ResponseT

Reset ACL logs. :rtype: Boolean.

For more information see https://redis.io/commands/acl-log

acl_save

acl_save(**kwargs) -> redis.commands.core.ResponseT

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

acl_users(**kwargs) -> redis.commands.core.ResponseT

Returns a list of all registered users on the server.

For more information see https://redis.io/commands/acl-users

acl_whoami

acl_whoami(**kwargs) -> redis.commands.core.ResponseT

Get the username for the current connection

For more information see https://redis.io/commands/acl-whoami

aclient_getname async

aclient_getname(**kwargs) -> redis.commands.core.ResponseT

Returns the current connection name

For more information see https://redis.io/commands/client-getname

Source code in kvdb/components/session.py
"""

def close_locks(
    self, 
    names: Optional[Union[List[str], str]] = None,
    force: Optional[bool] = False,

aclient_getredir async

aclient_getredir(**kwargs) -> redis.commands.core.ResponseT

Returns the ID (an integer) of the client to whom we are redirecting tracking notifications.

see: https://redis.io/commands/client-getredir

Source code in kvdb/components/session.py
    raise_errors: Optional[bool] = False,
):
    """
    Closes the locks that are currently managed by the session
    """
    if names is None: names = list(self.state.locks.keys())
    if isinstance(names, str): names = [names]

aclient_id async

aclient_id(**kwargs) -> redis.commands.core.ResponseT

Returns the current connection id

For more information see https://redis.io/commands/client-id

Source code in kvdb/components/session.py
        if name in self.state.alocks:
            await self.state.alocks[name].release(force = force, raise_errors = raise_errors)
            del self.state.alocks[name]


"""

aclient_info async

aclient_info(**kwargs) -> redis.commands.core.ResponseT

Returns information and statistics about the current client connection.

For more information see https://redis.io/commands/client-info

Source code in kvdb/components/session.py
storage so that a thread only sees its token, not a token set by
another thread. 
"""
if name not in self.state.alocks:
    self.state.alocks[name] = AsyncLock(
        self.aclient, 
        name = name, 

aclient_kill async

aclient_kill(
    address: str, **kwargs
) -> redis.commands.core.ResponseT

Disconnects the client at address (ip:port)

For more information see https://redis.io/commands/client-kill

Source code in kvdb/components/session.py
``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.

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
``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

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
            timeout = timeout, 
            sleep = sleep, 
            blocking = blocking, 
            blocking_timeout = blocking_timeout, 
            thread_local = thread_local
        )
    if self.state.alock is None: self.state.alock = self.state.alocks[name]
    return self.state.alocks[name]

"""
Lock Utility Methods

aclient_no_evict async

aclient_no_evict(
    mode: str,
) -> typing.Union[typing.Awaitable[str], str]

Sets the client eviction mode for the current connection.

For more information see https://redis.io/commands/client-no-evict

Source code in kvdb/components/session.py
    """
    return self.persistence.contains(key)


"""
Class Object Methods

aclient_no_touch async

aclient_no_touch(
    mode: str,
) -> typing.Union[typing.Awaitable[str], str]

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
"""

def close(self, close_pool: bool = False, force: Optional[bool] = None, raise_errors: bool = False):
    """
    Close the session
    """
    self.close_locks(force=force, raise_errors=raise_errors)
    if self.state.pubsub is not None:
        self.state.pubsub.close()

aclient_pause async

aclient_pause(
    timeout: int, all: bool = True, **kwargs
) -> redis.commands.core.ResponseT

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
        return ThreadPooler.create_background_task(
            self.asetitem, key, value,
        )
    return self.setitem(key, value)


def __getitem__(self, key: KeyT) -> ResponseT:
    """
    [Dict] Returns the value for the given key
    """
    return self.getitem(key)


def __delitem__(self, key: KeyT) -> None:
    """
    [Dict] Deletes the key
    """
    if settings.is_in_async_loop():

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
    for name in names:
        if name in self.state.locks:
            self.state.locks[name].release(force = force, raise_errors = raise_errors)
            del self.state.locks[name]

async def aclose_locks(
    self, 
    names: Optional[Union[List[str], str]] = None,
    force: Optional[bool] = False,
    raise_errors: Optional[bool] = False,
):
    """
    Closes the locks that are currently managed by the session
    """
    if names is None: names = list(self.state.alocks.keys())
    if isinstance(names, str): names = [names]
    for name in names:

aclient_setinfo async

aclient_setinfo(
    attr: str, value: str, **kwargs
) -> redis.commands.core.ResponseT

Sets the current connection library name or version For mor information see https://redis.io/commands/client-setinfo

Source code in kvdb/components/session.py
[Dict] Deletes the key
"""
return await self.persistence.adelete(key)

aclient_setname async

aclient_setname(
    name: str, **kwargs
) -> redis.commands.core.ResponseT

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.

Source code in kvdb/components/session.py
    key: KeyT,
) -> None:
    """
    [Dict] Deletes the key
    """
    return self.persistence.delete(key)

async def adelitem(
    self,
    key: KeyT,
) -> None:
    """

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
async def agetitem(
    self,
    key: KeyT,
    default: Optional[Any] = None,
) -> ResponseT:
    """
    [Dict] Returns the value for the given key
    """
    return await self.persistence.aget(key, default)


def setitem(
    self,
    key: KeyT,
    value: Any,
    ex: Optional[ExpiryT] = None,
    **kwargs: Any,
) -> None:
    """
    [Dict] Sets the value for the given key
    """
    return self.persistence.set(key, value, ex = ex, **kwargs)

async def asetitem(
    self,
    key: KeyT,
    value: Any,
    ex: Optional[ExpiryT] = None,
    **kwargs: Any,
) -> None:

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

Source code in kvdb/components/session.py
) -> ResponseT:
    """
    [Dict] Returns the value for the given key
    """
    return self.persistence.get(key, default)

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

Source code in kvdb/components/session.py
Dict-Like Interface Powered by `PersistentDict`
"""

def getitem(
    self,
    key: KeyT,
    default: Optional[Any] = None,

aclient_trackinginfo async

aclient_trackinginfo(
    **kwargs,
) -> redis.commands.core.ResponseT

Returns the information about the current client connection's use of the server assisted client side cache.

See https://redis.io/commands/client-trackinginfo

Source code in kvdb/components/session.py
    """
    [Dict] Sets the value for the given key
    """
    return await self.persistence.aset(key, value, ex = ex, **kwargs)

def delitem(
    self,

aclient_unblock async

aclient_unblock(
    client_id: int, error: bool = False, **kwargs
) -> redis.commands.core.ResponseT

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

Source code in kvdb/components/session.py
"""
Dict-Like Interface
"""

def __setitem__(self, key: KeyT, value: Any) -> None:
    """
    [Dict] Sets the value for the given key
    """
    if settings.is_in_async_loop():

aclient_unpause async

aclient_unpause(**kwargs) -> redis.commands.core.ResponseT

Unpause all redis clients

For more information see https://redis.io/commands/client-unpause

Source code in kvdb/components/session.py
        return ThreadPooler.create_background_task(self.adelitem, key)
    return self.delitem(key)

def __contains__(self, key: KeyT) -> bool:
    """
    [Dict] Returns whether the key exists

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
async def aclose(self, close_pool: bool = False, force: Optional[bool] = None, raise_errors: bool = False):
    """
    Close the session
    """
    await self.aclose_locks(force=force, raise_errors=raise_errors)
    if self.state.apubsub is not None:
        await self.state.apubsub.close()
        self.state.apubsub = None

    if self.state.aclient is not None:
        await self.state.aclient.close()
        if close_pool: await self.state.aclient.connection_pool.disconnect(raise_errors = raise_errors)
        self.state.aclient = None

    if self.state.client is not None:
        self.state.client.close()
        if close_pool: self.state.client.connection_pool.disconnect(raise_errors = raise_errors)
        self.state.client = None

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
async def aclose_locks(
    self, 
    names: Optional[Union[List[str], str]] = None,
    force: Optional[bool] = False,
    raise_errors: Optional[bool] = False,
):
    """
    Closes the locks that are currently managed by the session
    """
    if names is None: names = list(self.state.alocks.keys())
    if isinstance(names, str): names = [names]
    for name in names:
        if name in self.state.alocks:
            await self.state.alocks[name].release(force = force, raise_errors = raise_errors)
            del self.state.alocks[name]

acommand_docs async

acommand_docs(*args) -> None

This function throws a NotImplementedError since it is intentionally not supported.

Source code in kvdb/components/session.py
        if close_pool: self.state.client.connection_pool.disconnect(raise_errors = raise_errors)
        self.state.client = None


def __enter__(self):

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

Source code in kvdb/components/session.py
    await self.state.aclient.close()
    if close_pool: await self.state.aclient.connection_pool.disconnect(raise_errors = raise_errors)
    self.state.aclient = None

if self.state.client is not None:
    self.state.client.close()

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
async def aclose(self, close_pool: bool = False, force: Optional[bool] = None, raise_errors: bool = False):
    """
    Close the session
    """
    await self.aclose_locks(force=force, raise_errors=raise_errors)
    if self.state.apubsub is not None:
        await self.state.apubsub.close()
        self.state.apubsub = None

    if self.state.aclient is not None:

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

Source code in kvdb/components/session.py
    """
    Enter the runtime context related to this object.
    """
    return self

def __exit__(self, exc_type, exc_val, exc_tb):

aconfig_resetstat async

aconfig_resetstat(
    **kwargs,
) -> redis.commands.core.ResponseT

Reset runtime statistics

For more information see https://redis.io/commands/config-resetstat

Source code in kvdb/components/session.py
async def __aenter__(self):
    """
    Enter the runtime context related to this object.
    """
    return self

aconfig_rewrite async

aconfig_rewrite(**kwargs) -> redis.commands.core.ResponseT

Rewrite config file with the minimal change to reflect running config.

For more information see https://redis.io/commands/config-rewrite

Source code in kvdb/components/session.py
async def __aexit__(self, exc_type, exc_val, exc_tb):
    """
    Close the session
    """
    await self.aclose()

aconfig_set async

aconfig_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

Source code in kvdb/components/session.py
"""
On exit, close the session
"""
self.close()

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

adbsize(**kwargs) -> redis.commands.core.ResponseT

Returns the number of keys in the current database

For more information see https://redis.io/commands/dbsize

Source code in kvdb/components/session.py
"""
Class Wrap Methods
"""

def _client_function(self, *args, _function: Optional[str] = None, **kwargs) -> ResponseT:

adebug_object async

adebug_object(
    key: kvdb.types.generic.KeyT, **kwargs
) -> redis.commands.core.ResponseT

Returns version specific meta information about a given key

For more information see https://redis.io/commands/debug-object

Source code in kvdb/components/session.py
    """
    [Sync] Wraps the client function
    """
    return getattr(self.client, _function)(*args, **kwargs)

def _aclient_function(self, *args, _function: Optional[str] = None, **kwargs) -> Awaitable[ResponseT]:

adecrby async

adecrby(
    name: kvdb.types.generic.KeyT, amount: int = 1
) -> redis.commands.core.ResponseT

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

adelete(
    *names: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

Delete one or more keys specified by names

adelitem async

adelitem(key: kvdb.types.generic.KeyT) -> None

[Dict] Deletes the key

Source code in kvdb/components/session.py
async def adelitem(
    self,
    key: KeyT,
) -> None:
    """
    [Dict] Deletes the key
    """
    return await self.persistence.adelete(key)

adump async

adump(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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

aecho(
    value: redis.typing.EncodableT, **kwargs
) -> redis.commands.core.ResponseT

Echo the string back from the server

For more information see https://redis.io/commands/echo

Source code in kvdb/components/session.py
    [Async] Wraps the client function
    """
    return getattr(self.aclient, _function)(*args, **kwargs)


@classmethod

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

aexecute_command(
    *args: typing.Any, **options: typing.Any
) -> typing.Any

Execute a command and return a parsed response

Source code in kvdb/components/session.py
async def aexecute_command(self, *args: Any, **options: Any) -> Any:
    """
    Execute a command and return a parsed response
    """
    return await self.aclient.execute_command(*args, **options)

aexists async

aexists(
    *names: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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.

Valid options are

NX -> Set expiry only when the key has no expiry XX -> Set expiry only when the key has an existing expiry GT -> Set expiry only when the new expiry is greater than current one LT -> Set expiry only when the new expiry is less than current one

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.

Valid options are

-> NX -- Set expiry only when the key has no expiry -> XX -- Set expiry only when the key has an existing expiry -> GT -- Set expiry only when the new expiry is greater than current one -> LT -- Set expiry only when the new expiry is less than current one

For more information see https://redis.io/commands/expireat

aexpiretime async

aexpiretime(key: str) -> int

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

afailover() -> None

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

aflushall(
    asynchronous: bool = False, **kwargs
) -> redis.commands.core.ResponseT

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
def initialize_class_functions(cls):
    """
    Initializes the class methods
    and sets them based on both the async and sync methods
    """
    import inspect
    from makefun import create_function
    from redis.commands import (
        CoreCommands,

aflushdb async

aflushdb(
    asynchronous: bool = False, **kwargs
) -> redis.commands.core.ResponseT

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

Source code in kvdb/components/session.py
    # RedisModuleCommands,
    SentinelCommands,

    AsyncCoreCommands, 
    # AsyncRedisModuleCommands,
    AsyncSentinelCommands,
)

existing_methods = set(dir(cls))

afunction_delete async

afunction_delete(
    library: str,
) -> typing.Union[typing.Awaitable[str], str]

Delete the library called library and all its functions.

For more information see https://redis.io/commands/function-delete

afunction_dump async

afunction_dump() -> (
    typing.Union[typing.Awaitable[str], str]
)

Return the serialized payload of loaded libraries.

For more information see https://redis.io/commands/function-dump

afunction_flush async

afunction_flush(
    mode: str = "SYNC",
) -> typing.Union[typing.Awaitable[str], str]

Deletes all the libraries.

For more information see https://redis.io/commands/function-flush

afunction_kill async

afunction_kill() -> (
    typing.Union[typing.Awaitable[str], str]
)

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

afunction_stats() -> (
    typing.Union[typing.Awaitable[typing.List], typing.List]
)

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

aget(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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

agetbit(
    name: kvdb.types.generic.KeyT, offset: int
) -> redis.commands.core.ResponseT

Returns an integer indicating the value of offset in name

For more information see https://redis.io/commands/getbit

agetdel async

agetdel(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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

Source code in kvdb/components/session.py
async def agetitem(
    self,
    key: KeyT,
    default: Optional[Any] = None,
) -> ResponseT:
    """
    [Dict] Returns the value for the given key
    """
    return await self.persistence.aget(key, default)

agetrange async

agetrange(
    key: kvdb.types.generic.KeyT, start: int, end: int
) -> redis.commands.core.ResponseT

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

ahdel(
    name: str, *keys: typing.List
) -> typing.Union[typing.Awaitable[int], int]

Delete keys from hash name

For more information see https://redis.io/commands/hdel

ahello async

ahello() -> None

This function throws a NotImplementedError since it is intentionally not supported.

ahexists async

ahexists(
    name: str, key: str
) -> typing.Union[typing.Awaitable[bool], bool]

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

ahgetall(
    name: str,
) -> typing.Union[typing.Awaitable[dict], dict]

Return a Python dict of the hash's name/value pairs

For more information see https://redis.io/commands/hgetall

ahincrby async

ahincrby(
    name: str, key: str, amount: int = 1
) -> typing.Union[typing.Awaitable[int], int]

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

ahkeys(
    name: str,
) -> typing.Union[
    typing.Awaitable[typing.List], typing.List
]

Return the list of keys within hash name

For more information see https://redis.io/commands/hkeys

ahlen async

ahlen(
    name: str,
) -> typing.Union[typing.Awaitable[int], int]

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

ahmset(
    name: str, mapping: dict
) -> typing.Union[typing.Awaitable[str], str]

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

ahsetnx(
    name: str, key: str, value: str
) -> typing.Union[typing.Awaitable[bool], bool]

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

ahstrlen(
    name: str, key: str
) -> typing.Union[typing.Awaitable[int], int]

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

ahvals(
    name: str,
) -> typing.Union[
    typing.Awaitable[typing.List], typing.List
]

Return the list of values within hash name

For more information see https://redis.io/commands/hvals

aincrby async

aincrby(
    name: kvdb.types.generic.KeyT, amount: int = 1
) -> redis.commands.core.ResponseT

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

aincrbyfloat(
    name: kvdb.types.generic.KeyT, amount: float = 1.0
) -> redis.commands.core.ResponseT

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
# Async Methods
for amodule in {
    AsyncCoreCommands,
    # AsyncRedisModuleCommands,
    AsyncSentinelCommands,
}:
    # Core Commands
    for name in dir(amodule):
        if name.startswith('_'): continue
        aname = f'a{name}'
        # if aname == 'async': aname = 'asyncronize'

akeys async

akeys(
    pattern: redis.typing.PatternT = "*", **kwargs
) -> redis.commands.core.ResponseT

Returns a list of keys matching pattern

For more information see https://redis.io/commands/keys

alastsave async

alastsave(**kwargs) -> redis.commands.core.ResponseT

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

Source code in kvdb/components/session.py
if aname in {
    'async', 'await'
}:
    aname = f'{aname}_'
if aname in existing_methods: continue
# if name in skip_methods: continue
existing_func = getattr(amodule, name)

alatency_doctor async

alatency_doctor() -> None

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

Source code in kvdb/components/session.py
existing_sig = inspect.signature(existing_func)
try:
    new_func = create_function(
        existing_sig,
        functools.partial(cls._aclient_function, _function = name),
        func_name = aname,

alatency_graph async

alatency_graph() -> None

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.

Source code in kvdb/components/session.py
        module_name = cls.__module__,
    )
    setattr(cls, aname, new_func)
    existing_methods.add(aname)
    added_methods.add(aname)
except Exception as e:

alatency_histogram async

alatency_histogram(*args) -> None

This function throws a NotImplementedError since it is intentionally not supported.

alatency_history async

alatency_history(
    event: str,
) -> redis.commands.core.ResponseT

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

alatency_latest() -> redis.commands.core.ResponseT

Reports the latest latency events logged.

For more information see https://redis.io/commands/latency-latest

alatency_reset async

alatency_reset(
    *events: str,
) -> redis.commands.core.ResponseT

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

allen(
    name: str,
) -> typing.Union[typing.Awaitable[int], int]

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
def alock(
    self, 
    name: str, 
    timeout: Optional[Number] = None,
    sleep: Number = 0.1,
    blocking: bool = True,
    blocking_timeout: Optional[Number] = None,
    thread_local: bool = True,
    **kwargs,
) -> 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. 
    """
    if name not in self.state.alocks:
        self.state.alocks[name] = AsyncLock(
            self.aclient, 
            name = name, 
            timeout = timeout, 
            sleep = sleep, 
            blocking = blocking, 
            blocking_timeout = blocking_timeout, 
            thread_local = thread_local
        )
    if self.state.alock is None: self.state.alock = self.state.alocks[name]
    return self.state.alocks[name]

alolwut async

alolwut(
    *version_numbers: typing.Union[str, float], **kwargs
) -> redis.commands.core.ResponseT

Get the Redis version and a piece of generative computer art

See: https://redis.io/commands/lolwut

Source code in kvdb/components/session.py
            print(f"Error adding method: {name} -> {aname}")
            raise e

# print('Added Methods: ', added_methods)

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

alpush(
    name: str, *values: redis.typing.FieldT
) -> typing.Union[typing.Awaitable[int], int]

Push values onto the head of the list name

For more information see https://redis.io/commands/lpush

alpushx async

alpushx(
    name: str, *values: redis.typing.FieldT
) -> typing.Union[typing.Awaitable[int], int]

Push value onto the head of the list name if name exists

For more information see https://redis.io/commands/lpushx

alrange async

alrange(
    name: str, start: int, end: int
) -> typing.Union[typing.Awaitable[list], list]

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

alrem(
    name: str, count: int, value: str
) -> typing.Union[typing.Awaitable[int], int]

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

alset(
    name: str, index: int, value: str
) -> typing.Union[typing.Awaitable[str], str]

Set element at index of list name to value

For more information see https://redis.io/commands/lset

altrim async

altrim(
    name: str, start: int, end: int
) -> typing.Union[typing.Awaitable[str], str]

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

amemory_malloc_stats(
    **kwargs,
) -> redis.commands.core.ResponseT

Return an internal statistics report from the memory allocator.

See: https://redis.io/commands/memory-malloc-stats

amemory_purge async

amemory_purge(**kwargs) -> redis.commands.core.ResponseT

Attempts to purge dirty pages for reclamation by allocator

For more information see https://redis.io/commands/memory-purge

amemory_stats async

amemory_stats(**kwargs) -> redis.commands.core.ResponseT

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

amget(
    keys: redis.typing.KeysT, *args: redis.typing.EncodableT
) -> redis.commands.core.ResponseT

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

amodule_list() -> redis.commands.core.ResponseT

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

amodule_load(path, *args) -> redis.commands.core.ResponseT

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

amodule_unload(name) -> redis.commands.core.ResponseT

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

amove(
    name: kvdb.types.generic.KeyT, db: int
) -> redis.commands.core.ResponseT

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

aobject(
    infotype: str, key: kvdb.types.generic.KeyT, **kwargs
) -> redis.commands.core.ResponseT

Return the encoding, idletime, or refcount about the key

aoverflow async

aoverflow(overflow: str)

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

apersist(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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.

Valid options are

NX -> Set expiry only when the key has no expiry XX -> Set expiry only when the key has an existing expiry GT -> Set expiry only when the new expiry is greater than current one LT -> Set expiry only when the new expiry is less than current one

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.

Valid options are

NX -> Set expiry only when the key has no expiry XX -> Set expiry only when the key has an existing expiry GT -> Set expiry only when the new expiry is greater than current one LT -> Set expiry only when the new expiry is less than current one

For more information see https://redis.io/commands/pexpireat

apexpiretime async

apexpiretime(key: str) -> int

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

apfcount(
    *sources: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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

aping(**kwargs) -> redis.commands.core.ResponseT

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
def apipeline(
    self, 
    transaction: Optional[bool] = True, 
    shard_hint: Optional[str] = None, 
    retryable: Optional[bool] = None,
    **kwargs
) -> 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.
    """
    if retryable is None: retryable = self.settings.retry.pipeline_enabled
    return self.aclient.pipeline(transaction = transaction, shard_hint = shard_hint, retryable = retryable)

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

apsync(replicationid: str, offset: int)

Initiates a replication stream from the master. Newer version for sync.

For more information see https://redis.io/commands/sync

Source code in kvdb/components/session.py
    SentinelCommands,
}:

    for name in dir(sync_module):
        if name.startswith('_'): continue
        if name in existing_methods: continue
        # if name in skip_methods: continue

apttl async

apttl(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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

apubsub(
    retryable: typing.Optional[bool] = None, **kwargs
) -> kvdb.components.pubsub.AsyncPubSubT

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
def apubsub(
    self, 
    retryable: Optional[bool] = None,
    **kwargs
) -> AsyncPubSubT:
    """
    Return a Publish/Subscribe object. With this object, you can
    subscribe to channels and listen for messages that get published to
    """
    if retryable is None: retryable = self.settings.retry.pubsub_enabled
    return self.aclient.pubsub(retryable = retryable, **kwargs)

apubsub_channels async

apubsub_channels(
    pattern: redis.typing.PatternT = "*", **kwargs
) -> redis.commands.core.ResponseT

Return a list of channels that have at least one subscriber

For more information see https://redis.io/commands/pubsub-channels

apubsub_numpat async

apubsub_numpat(**kwargs) -> redis.commands.core.ResponseT

Returns the number of subscriptions to patterns

For more information see https://redis.io/commands/pubsub-numpat

apubsub_numsub async

apubsub_numsub(
    *args: redis.typing.ChannelT, **kwargs
) -> redis.commands.core.ResponseT

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

apubsub_shardnumsub(
    *args: redis.typing.ChannelT, **kwargs
) -> redis.commands.core.ResponseT

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

aquit(**kwargs) -> redis.commands.core.ResponseT

Ask the server to close the connection.

For more information see https://redis.io/commands/quit

arandomkey async

arandomkey(**kwargs) -> redis.commands.core.ResponseT

Returns the name of a random key

For more information see https://redis.io/commands/randomkey

areadonly async

areadonly(**kwargs) -> redis.commands.core.ResponseT

Enables read queries for a connection to a Redis Cluster replica node.

For more information see https://redis.io/commands/readonly

areadwrite async

areadwrite(**kwargs) -> redis.commands.core.ResponseT

Disables read queries for a connection to a Redis Cluster slave node.

For more information see https://redis.io/commands/readwrite

aregister_script async

aregister_script(
    script: redis.typing.ScriptTextT,
) -> redis.commands.core.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.

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

arenamenx(
    src: kvdb.types.generic.KeyT,
    dst: kvdb.types.generic.KeyT,
)

Rename key src to dst if dst doesn't already exist

For more information see https://redis.io/commands/renamenx

areplicaof async

areplicaof(
    *args, **kwargs
) -> redis.commands.core.ResponseT

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

areset async

areset() -> None

Reset the state of the instance to when it was constructed

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

arole() -> redis.commands.core.ResponseT

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
"""
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.

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

arpoplpush(
    src: str, dst: str
) -> typing.Union[typing.Awaitable[str], str]

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

arpush(
    name: str, *values: redis.typing.FieldT
) -> typing.Union[typing.Awaitable[int], int]

Push values onto the tail of the list name

For more information see https://redis.io/commands/rpush

arpushx async

arpushx(
    name: str, *values: str
) -> typing.Union[typing.Awaitable[int], int]

Push value onto the tail of the list name if name exists

For more information see https://redis.io/commands/rpushx

asadd async

asadd(
    name: str, *values: redis.typing.FieldT
) -> typing.Union[typing.Awaitable[int], int]

Add value(s) to set name

For more information see https://redis.io/commands/sadd

asave async

asave(**kwargs) -> redis.commands.core.ResponseT

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

ascard(
    name: str,
) -> typing.Union[typing.Awaitable[int], int]

Return the number of elements in set name

For more information see https://redis.io/commands/scard

ascript_exists async

ascript_exists(*args: str) -> redis.commands.core.ResponseT

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

ascript_kill() -> redis.commands.core.ResponseT

Kill the currently executing Lua script

For more information see https://redis.io/commands/script-kill

ascript_load async

ascript_load(
    script: redis.typing.ScriptTextT,
) -> redis.commands.core.ResponseT

Load a Lua script into the script cache. Returns the SHA.

For more information see https://redis.io/commands/script-load

asdiff async

asdiff(
    keys: typing.List, *args: typing.List
) -> typing.Union[typing.Awaitable[list], list]

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

aselect(
    index: int, **kwargs
) -> redis.commands.core.ResponseT

Select the Redis logical database at index.

See: https://redis.io/commands/select

Source code in kvdb/components/session.py
    module_name = cls.__module__,
)
setattr(cls, name, new_func)
existing_methods.add(name)
added_methods.add(name)

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

asetbit(
    name: kvdb.types.generic.KeyT, offset: int, value: int
) -> redis.commands.core.ResponseT

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
async def asetitem(
    self,
    key: KeyT,
    value: Any,
    ex: Optional[ExpiryT] = None,
    **kwargs: Any,
) -> None:
    """
    [Dict] Sets the value for the given key
    """
    return await self.persistence.aset(key, value, ex = ex, **kwargs)

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

asinter(
    keys: typing.List, *args: typing.List
) -> typing.Union[typing.Awaitable[list], list]

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

aslowlog_get(
    num: typing.Union[int, None] = None, **kwargs
) -> redis.commands.core.ResponseT

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

aslowlog_len(**kwargs) -> redis.commands.core.ResponseT

Get the number of items in the slowlog

For more information see https://redis.io/commands/slowlog-len

aslowlog_reset async

aslowlog_reset(**kwargs) -> redis.commands.core.ResponseT

Remove all items in the slowlog

For more information see https://redis.io/commands/slowlog-reset

asmembers async

asmembers(
    name: str,
) -> typing.Union[typing.Awaitable[typing.Set], typing.Set]

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

asmove(
    src: str, dst: str, value: str
) -> typing.Union[typing.Awaitable[bool], bool]

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

aspop(
    name: str, count: typing.Optional[int] = None
) -> typing.Union[str, typing.List, None]

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

asrem(
    name: str, *values: redis.typing.FieldT
) -> typing.Union[typing.Awaitable[int], int]

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

astrlen(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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

aswapdb(
    first: int, second: int, **kwargs
) -> redis.commands.core.ResponseT

Swap two databases

For more information see https://redis.io/commands/swapdb

Source code in kvdb/components/session.py
existing_func = getattr(sync_module, name)
existing_sig = inspect.signature(existing_func)
new_func = create_function(
    existing_sig,
    functools.partial(cls._client_function, _function = name),
    func_name = name,

async_ async

async_() -> redis.commands.core.ResponseT

Initiates a replication stream from the master.

For more information see https://redis.io/commands/sync

Source code in kvdb/components/session.py
added_methods = set()

# Sync Methods
for sync_module in {
    CoreCommands,
    # RedisModuleCommands,

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

atfunction_delete(
    lib_name: str,
) -> redis.commands.core.ResponseT

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

atime(**kwargs) -> redis.commands.core.ResponseT

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

atouch(
    *args: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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

attl(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

Returns the number of seconds until the key name will expire

For more information see https://redis.io/commands/ttl

atype async

atype(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

Returns the type of key name

For more information see https://redis.io/commands/type

aunlink(
    *names: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

Unlink one or more keys specified by names

For more information see https://redis.io/commands/unlink

aunwatch async

aunwatch() -> None

Unwatches the value at key name, or None of the key doesn't exist

For more information see https://redis.io/commands/unwatch

auth

auth(
    password: str,
    username: typing.Optional[str] = None,
    **kwargs
)

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

await_(
    num_replicas: int, timeout: int, **kwargs
) -> redis.commands.core.ResponseT

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

awatch(*names: kvdb.types.generic.KeyT) -> None

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

axinfo_groups(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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

axinfo_stream(
    name: kvdb.types.generic.KeyT, full: bool = False
) -> redis.commands.core.ResponseT

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

axlen(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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

azcard(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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

azdiff(
    keys: redis.typing.KeysT, withscores: bool = False
) -> redis.commands.core.ResponseT

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

azlexcount(name, min, max)

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

bgrewriteaof(**kwargs)

Tell the Redis server to rewrite the AOF file from data in memory.

For more information see https://redis.io/commands/bgrewriteaof

bgsave

bgsave(
    schedule: bool = True, **kwargs
) -> redis.commands.core.ResponseT

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

client_getname(**kwargs) -> redis.commands.core.ResponseT

Returns the current connection name

For more information see https://redis.io/commands/client-getname

client_getredir

client_getredir(**kwargs) -> redis.commands.core.ResponseT

Returns the ID (an integer) of the client to whom we are redirecting tracking notifications.

see: https://redis.io/commands/client-getredir

client_id

client_id(**kwargs) -> redis.commands.core.ResponseT

Returns the current connection id

For more information see https://redis.io/commands/client-id

client_info

client_info(**kwargs) -> redis.commands.core.ResponseT

Returns information and statistics about the current client connection.

For more information see https://redis.io/commands/client-info

client_kill

client_kill(
    address: str, **kwargs
) -> redis.commands.core.ResponseT

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

client_no_evict(
    mode: str,
) -> typing.Union[typing.Awaitable[str], str]

Sets the client eviction mode for the current connection.

For more information see https://redis.io/commands/client-no-evict

client_no_touch

client_no_touch(
    mode: str,
) -> typing.Union[typing.Awaitable[str], str]

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

client_pause(
    timeout: int, all: bool = True, **kwargs
) -> redis.commands.core.ResponseT

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

client_setinfo(
    attr: str, value: str, **kwargs
) -> redis.commands.core.ResponseT

Sets the current connection library name or version For mor information see https://redis.io/commands/client-setinfo

client_setname

client_setname(
    name: str, **kwargs
) -> redis.commands.core.ResponseT

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

client_trackinginfo(
    **kwargs,
) -> redis.commands.core.ResponseT

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

client_unblock(
    client_id: int, error: bool = False, **kwargs
) -> redis.commands.core.ResponseT

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

client_unpause(**kwargs) -> redis.commands.core.ResponseT

Unpause all redis clients

For more information see https://redis.io/commands/client-unpause

close

close(
    close_pool: bool = False,
    force: typing.Optional[bool] = None,
    raise_errors: bool = False,
)

Close the session

Source code in kvdb/components/session.py
def close(self, close_pool: bool = False, force: Optional[bool] = None, raise_errors: bool = False):
    """
    Close the session
    """
    self.close_locks(force=force, raise_errors=raise_errors)
    if self.state.pubsub is not None:
        self.state.pubsub.close()
        self.state.pubsub = None

    if self.state.client is not None:
        self.state.client.close()
        if close_pool:
            self.state.client.connection_pool.disconnect(raise_errors = raise_errors)
        self.state.client = None

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
def close_locks(
    self, 
    names: Optional[Union[List[str], str]] = None,
    force: Optional[bool] = False,
    raise_errors: Optional[bool] = False,
):
    """
    Closes the locks that are currently managed by the session
    """
    if names is None: names = list(self.state.locks.keys())
    if isinstance(names, str): names = [names]
    for name in names:
        if name in self.state.locks:
            self.state.locks[name].release(force = force, raise_errors = raise_errors)
            del self.state.locks[name]

command_docs

command_docs(*args) -> None

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

config_resetstat(**kwargs) -> redis.commands.core.ResponseT

Reset runtime statistics

For more information see https://redis.io/commands/config-resetstat

config_rewrite

config_rewrite(**kwargs) -> redis.commands.core.ResponseT

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
def create_persistence(
    self,
    name: Optional[str] = None,
    base_key: Optional[str] = None,
    **kwargs,
) -> 'PersistentDict':
    """
    Create a new persistence instance
    """
    # name = name or self.name
    # if name in self._persistence_ctx:
    #     return self._persistence_ctx[name]

    from .persistence import KVDBStatefulBackend
    persistence_config = self.settings.persistence.model_dump(exclude_none = True)
    persistence_kwargs = self.settings.persistence.extract_kwargs(_prefix = 'persistence_', _exclude_none = True, **self._kwargs)
    if persistence_kwargs: persistence_config.update(persistence_kwargs)
    if 'name' not in persistence_config: persistence_config['name'] = self.name
    if base_key is not None: persistence_config['base_key'] = base_key
    persistence_config.update(kwargs)
    base_key = persistence_config.get('base_key')
    if base_key in self._persistence_ctx:
        return self._persistence_ctx[base_key]
    p = KVDBStatefulBackend.as_persistent_dict(
        session = self,
        **persistence_config,
    )
    self._persistence_ctx[base_key] = p
    return p

dbsize

dbsize(**kwargs) -> redis.commands.core.ResponseT

Returns the number of keys in the current database

For more information see https://redis.io/commands/dbsize

debug_object

debug_object(
    key: kvdb.types.generic.KeyT, **kwargs
) -> redis.commands.core.ResponseT

Returns version specific meta information about a given key

For more information see https://redis.io/commands/debug-object

decrby

decrby(
    name: kvdb.types.generic.KeyT, amount: int = 1
) -> redis.commands.core.ResponseT

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(
    *names: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

Delete one or more keys specified by names

delitem

delitem(key: kvdb.types.generic.KeyT) -> None

[Dict] Deletes the key

Source code in kvdb/components/session.py
def delitem(
    self,
    key: KeyT,
) -> None:
    """
    [Dict] Deletes the key
    """
    return self.persistence.delete(key)

disable_serialization

disable_serialization(
    decode_responses: typing.Optional[bool] = None,
)

Disable Serialization in the Encoder

Source code in kvdb/components/session.py
def disable_serialization(self, decode_responses: Optional[bool] = None):
    """
    Disable Serialization in the Encoder
    """
    self.encoder.disable_serialization(decode_responses=decode_responses)
    self.pool.disable_serialization(decode_responses=decode_responses)

dump

dump(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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(
    value: redis.typing.EncodableT, **kwargs
) -> redis.commands.core.ResponseT

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
def enable_serialization(self, serializer: Optional['SerializerT'] = None, decode_responses: Optional[bool] = None):
    """
    Enable Serialization in the Encoder
    """
    self.encoder.enable_serialization(serializer = serializer, decode_responses = decode_responses)
    self.pool.enable_serialization(serializer = serializer, decode_responses = decode_responses)

eval

eval(
    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

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

evalsha(
    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

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

execute_command(
    *args: typing.Any, **options: typing.Any
) -> typing.Any

Execute a command and return a parsed response

Source code in kvdb/components/session.py
def execute_command(self, *args: Any, **options: Any) -> Any:
    """
    Execute a command and return a parsed response
    """
    return self.client.execute_command(*args, **options)

exists

exists(
    *names: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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.

Valid options are

NX -> Set expiry only when the key has no expiry XX -> Set expiry only when the key has an existing expiry GT -> Set expiry only when the new expiry is greater than current one LT -> Set expiry only when the new expiry is less than current one

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.

Valid options are

-> NX -- Set expiry only when the key has no expiry -> XX -- Set expiry only when the key has an existing expiry -> GT -- Set expiry only when the new expiry is greater than current one -> LT -- Set expiry only when the new expiry is less than current one

For more information see https://redis.io/commands/expireat

expiretime

expiretime(key: str) -> int

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

failover() -> None

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

flushall(
    asynchronous: bool = False, **kwargs
) -> redis.commands.core.ResponseT

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

flushdb(
    asynchronous: bool = False, **kwargs
) -> redis.commands.core.ResponseT

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

function_delete(
    library: str,
) -> typing.Union[typing.Awaitable[str], str]

Delete the library called library and all its functions.

For more information see https://redis.io/commands/function-delete

function_dump

function_dump() -> typing.Union[typing.Awaitable[str], str]

Return the serialized payload of loaded libraries.

For more information see https://redis.io/commands/function-dump

function_flush

function_flush(
    mode: str = "SYNC",
) -> typing.Union[typing.Awaitable[str], str]

Deletes all the libraries.

For more information see https://redis.io/commands/function-flush

function_kill

function_kill() -> typing.Union[typing.Awaitable[str], str]

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

function_stats() -> (
    typing.Union[typing.Awaitable[typing.List], typing.List]
)

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

get(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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

get_dictkey(key: kvdb.types.generic.KeyT) -> str

Returns the dict key

Source code in kvdb/components/session.py
        dict_expiration = kwargs.get('dict_expiration'),
    )

@property

getbit

getbit(
    name: kvdb.types.generic.KeyT, offset: int
) -> redis.commands.core.ResponseT

Returns an integer indicating the value of offset in name

For more information see https://redis.io/commands/getbit

getdel

getdel(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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

getitem(
    key: kvdb.types.generic.KeyT,
    default: typing.Optional[typing.Any] = None,
) -> kvdb.components.session.ReturnT

[Dict] Returns the value for the given key

Source code in kvdb/components/session.py
def getitem(
    self,
    key: KeyT,
    default: Optional[Any] = None,
) -> ResponseT:
    """
    [Dict] Returns the value for the given key
    """
    return self.persistence.get(key, default)

getrange

getrange(
    key: kvdb.types.generic.KeyT, start: int, end: int
) -> redis.commands.core.ResponseT

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

hdel(
    name: str, *keys: typing.List
) -> typing.Union[typing.Awaitable[int], int]

Delete keys from hash name

For more information see https://redis.io/commands/hdel

hello

hello() -> None

This function throws a NotImplementedError since it is intentionally not supported.

hexists

hexists(
    name: str, key: str
) -> typing.Union[typing.Awaitable[bool], bool]

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

hgetall(
    name: str,
) -> typing.Union[typing.Awaitable[dict], dict]

Return a Python dict of the hash's name/value pairs

For more information see https://redis.io/commands/hgetall

hincrby

hincrby(
    name: str, key: str, amount: int = 1
) -> typing.Union[typing.Awaitable[int], int]

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

hkeys(
    name: str,
) -> typing.Union[
    typing.Awaitable[typing.List], typing.List
]

Return the list of keys within hash name

For more information see https://redis.io/commands/hkeys

hlen

hlen(name: str) -> typing.Union[typing.Awaitable[int], int]

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

hmset(
    name: str, mapping: dict
) -> typing.Union[typing.Awaitable[str], str]

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

hsetnx(
    name: str, key: str, value: str
) -> typing.Union[typing.Awaitable[bool], bool]

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

hstrlen(
    name: str, key: str
) -> typing.Union[typing.Awaitable[int], int]

Return the number of bytes stored in the value of key within hash name

For more information see https://redis.io/commands/hstrlen

hvals

hvals(
    name: str,
) -> typing.Union[
    typing.Awaitable[typing.List], typing.List
]

Return the list of values within hash name

For more information see https://redis.io/commands/hvals

incrby

incrby(
    name: kvdb.types.generic.KeyT, amount: int = 1
) -> redis.commands.core.ResponseT

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

incrbyfloat(
    name: kvdb.types.generic.KeyT, amount: float = 1.0
) -> redis.commands.core.ResponseT

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

init_cache_config(**kwargs: typing.Any) -> None

Initializes the cache config

Source code in kvdb/components/session.py
def init_cache_config(self, **kwargs: Any) -> None:
    """
    Initializes the cache config
    """
    _cache_config = settings.cache.extract_kwargs(_prefix = 'cache_', _exclude_none = True, **kwargs)
    self.cache_config = settings.cache.model_copy(update = _cache_config, deep = True)

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
def init_encoder(
    self, 
    encoder: Optional['Encoder'] = None, 
    **kwargs: Any
) -> None:
    """
    Initializes the encoder
    """
    if encoder is None:
        from kvdb.io.encoder import Encoder
        serializer_disabled = kwargs.get(
            'serializer_disabled', self.serializer is None
        )
        encoder = Encoder(
            encoding = kwargs.get('encoding', 'utf-8'),
            encoding_errors = kwargs.get('encoding_errors', 'strict'),
            decode_responses = kwargs.get('decode_responses'),
            serializer = None if serializer_disabled else self.serializer,
        )
    self.encoder = encoder

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
def init_serializer(
    self, 
    serializer: Optional[Union['SerializerT', str]] = None, 
    **kwargs: Any
) -> None:
    """
    Initializes the serializer
    """

    if serializer is None or isinstance(serializer, str):
        _serializer_kwargs = SerializerConfig.extract_kwargs(
            _include = ('raise_errors'), 
            **kwargs
        )

        # self.settings.logger.info(f'Initializing serializer for {self.name}, {_serializer_kwargs}')
        serializer = settings.client_config.get_serializer(
            serializer = serializer,
            **_serializer_kwargs,
        )
        if self.settings.debug:
            self.settings.logger.info(f'Initialized serializer for {self.name}, {serializer.name if serializer else None} {_serializer_kwargs}')
    self.serializer = serializer

init_state

init_state(**kwargs: typing.Any) -> None

Initializes the session state

Source code in kvdb/components/session.py
def init_state(self, **kwargs: Any) -> None:
    """
    Initializes the session state
    """
    self.state = SessionState(
        cache_max_attempts = self.cache_config.max_attempts,
        dict_method = kwargs.get('dict_method', 'hset'),
        dict_prefix = kwargs.get('dict_prefix', f'{self.name}.dict'),
        dict_serialize = kwargs.get('dict_serialize', True),
        dict_expiration = kwargs.get('dict_expiration'),
    )

initialize_class_functions classmethod

initialize_class_functions()

Initializes the class methods and sets them based on both the async and sync methods

Source code in kvdb/components/session.py
@classmethod
def initialize_class_functions(cls):
    """
    Initializes the class methods
    and sets them based on both the async and sync methods
    """
    import inspect
    from makefun import create_function
    from redis.commands import (
        CoreCommands,
        # RedisModuleCommands,
        SentinelCommands,

        AsyncCoreCommands, 
        # AsyncRedisModuleCommands,
        AsyncSentinelCommands,
    )

    existing_methods = set(dir(cls))
    added_methods = set()

    # Sync Methods
    for sync_module in {
        CoreCommands,
        # RedisModuleCommands,
        SentinelCommands,
    }:

        for name in dir(sync_module):
            if name.startswith('_'): continue
            if name in existing_methods: continue
            # if name in skip_methods: continue
            existing_func = getattr(sync_module, name)
            existing_sig = inspect.signature(existing_func)
            new_func = create_function(
                existing_sig,
                functools.partial(cls._client_function, _function = name),
                func_name = name,
                module_name = cls.__module__,
            )
            setattr(cls, name, new_func)
            existing_methods.add(name)
            added_methods.add(name)

    # Async Methods
    for amodule in {
        AsyncCoreCommands,
        # AsyncRedisModuleCommands,
        AsyncSentinelCommands,
    }:
        # Core Commands
        for name in dir(amodule):
            if name.startswith('_'): continue
            aname = f'a{name}'
            # if aname == 'async': aname = 'asyncronize'
            if aname in {
                'async', 'await'
            }:
                aname = f'{aname}_'
            if aname in existing_methods: continue
            # if name in skip_methods: continue
            existing_func = getattr(amodule, name)
            existing_sig = inspect.signature(existing_func)
            try:
                new_func = create_function(
                    existing_sig,
                    functools.partial(cls._aclient_function, _function = name),
                    func_name = aname,
                    module_name = cls.__module__,
                )
                setattr(cls, aname, new_func)
                existing_methods.add(aname)
                added_methods.add(aname)
            except Exception as e:
                print(f"Error adding method: {name} -> {aname}")
                raise e

keys

keys(
    pattern: redis.typing.PatternT = "*", **kwargs
) -> redis.commands.core.ResponseT

Returns a list of keys matching pattern

For more information see https://redis.io/commands/keys

lastsave

lastsave(**kwargs) -> redis.commands.core.ResponseT

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

latency_doctor() -> None

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

latency_graph() -> None

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

latency_histogram(*args) -> None

This function throws a NotImplementedError since it is intentionally not supported.

latency_history

latency_history(
    event: str,
) -> redis.commands.core.ResponseT

Returns the raw data of the event's latency spikes time series.

For more information see https://redis.io/commands/latency-history

latency_latest

latency_latest() -> redis.commands.core.ResponseT

Reports the latest latency events logged.

For more information see https://redis.io/commands/latency-latest

latency_reset

latency_reset(
    *events: str,
) -> redis.commands.core.ResponseT

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

llen(name: str) -> typing.Union[typing.Awaitable[int], int]

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
def lock(
    self, 
    name: str, 
    timeout: Optional[Number] = None,
    sleep: Optional[Number] = 0.1,
    blocking: Optional[bool] = True,
    blocking_timeout: Optional[Number] = None,
    thread_local: Optional[bool] = True,
    **kwargs,
) -> 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. 
    """
    if name not in self.state.locks:
        self.state.locks[name] = Lock(
            self.client, 
            name = name, 
            timeout = timeout, 
            sleep = sleep, 
            blocking = blocking, 
            blocking_timeout = blocking_timeout, 
            thread_local = thread_local
        )
    if self.state.lock is None: self.state.lock = self.state.locks[name]
    return self.state.locks[name]

lolwut

lolwut(
    *version_numbers: typing.Union[str, float], **kwargs
) -> redis.commands.core.ResponseT

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

lpush(
    name: str, *values: redis.typing.FieldT
) -> typing.Union[typing.Awaitable[int], int]

Push values onto the head of the list name

For more information see https://redis.io/commands/lpush

lpushx

lpushx(
    name: str, *values: redis.typing.FieldT
) -> typing.Union[typing.Awaitable[int], int]

Push value onto the head of the list name if name exists

For more information see https://redis.io/commands/lpushx

lrange

lrange(
    name: str, start: int, end: int
) -> typing.Union[typing.Awaitable[list], list]

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

lrem(
    name: str, count: int, value: str
) -> typing.Union[typing.Awaitable[int], int]

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

lset(
    name: str, index: int, value: str
) -> typing.Union[typing.Awaitable[str], str]

Set element at index of list name to value

For more information see https://redis.io/commands/lset

ltrim

ltrim(
    name: str, start: int, end: int
) -> typing.Union[typing.Awaitable[str], str]

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

memory_malloc_stats(
    **kwargs,
) -> redis.commands.core.ResponseT

Return an internal statistics report from the memory allocator.

See: https://redis.io/commands/memory-malloc-stats

memory_purge

memory_purge(**kwargs) -> redis.commands.core.ResponseT

Attempts to purge dirty pages for reclamation by allocator

For more information see https://redis.io/commands/memory-purge

memory_stats

memory_stats(**kwargs) -> redis.commands.core.ResponseT

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

mget(
    keys: redis.typing.KeysT, *args: redis.typing.EncodableT
) -> redis.commands.core.ResponseT

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

module_list() -> redis.commands.core.ResponseT

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

module_load(path, *args) -> redis.commands.core.ResponseT

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

module_unload(name) -> redis.commands.core.ResponseT

Unloads the module name. Raises ModuleError if name is not in loaded modules.

For more information see https://redis.io/commands/module-unload

move

move(
    name: kvdb.types.generic.KeyT, db: int
) -> redis.commands.core.ResponseT

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

object(
    infotype: str, key: kvdb.types.generic.KeyT, **kwargs
) -> redis.commands.core.ResponseT

Return the encoding, idletime, or refcount about the key

overflow

overflow(overflow: str)

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

persist(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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.

Valid options are

NX -> Set expiry only when the key has no expiry XX -> Set expiry only when the key has an existing expiry GT -> Set expiry only when the new expiry is greater than current one LT -> Set expiry only when the new expiry is less than current one

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.

Valid options are

NX -> Set expiry only when the key has no expiry XX -> Set expiry only when the key has an existing expiry GT -> Set expiry only when the new expiry is greater than current one LT -> Set expiry only when the new expiry is less than current one

For more information see https://redis.io/commands/pexpireat

pexpiretime

pexpiretime(key: str) -> int

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

pfcount(
    *sources: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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(**kwargs) -> redis.commands.core.ResponseT

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
def pipeline(
    self, 
    transaction: Optional[bool] = True, 
    shard_hint: Optional[str] = None, 
    retryable: Optional[bool] = None,
    **kwargs
) -> 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.
    """
    if retryable is None: retryable = self.settings.retry.pipeline_enabled
    return self.client.pipeline(transaction = transaction, shard_hint = shard_hint, retryable = retryable)

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

psync(replicationid: str, offset: int)

Initiates a replication stream from the master. Newer version for sync.

For more information see https://redis.io/commands/sync

pttl

pttl(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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

pubsub(
    retryable: typing.Optional[bool] = None, **kwargs
) -> kvdb.components.pubsub.PubSubT

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
def pubsub(
    self, 
    retryable: Optional[bool] = None,
    **kwargs
) -> PubSubT:
    """
    Return a Publish/Subscribe object. With this object, you can
    subscribe to channels and listen for messages that get published to
    """
    if retryable is None: retryable = self.settings.retry.pubsub_enabled
    return self.client.pubsub(retryable = retryable, **kwargs)

pubsub_channels

pubsub_channels(
    pattern: redis.typing.PatternT = "*", **kwargs
) -> redis.commands.core.ResponseT

Return a list of channels that have at least one subscriber

For more information see https://redis.io/commands/pubsub-channels

pubsub_numpat

pubsub_numpat(**kwargs) -> redis.commands.core.ResponseT

Returns the number of subscriptions to patterns

For more information see https://redis.io/commands/pubsub-numpat

pubsub_numsub

pubsub_numsub(
    *args: redis.typing.ChannelT, **kwargs
) -> redis.commands.core.ResponseT

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

pubsub_shardnumsub(
    *args: redis.typing.ChannelT, **kwargs
) -> redis.commands.core.ResponseT

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

quit(**kwargs) -> redis.commands.core.ResponseT

Ask the server to close the connection.

For more information see https://redis.io/commands/quit

randomkey

randomkey(**kwargs) -> redis.commands.core.ResponseT

Returns the name of a random key

For more information see https://redis.io/commands/randomkey

readonly

readonly(**kwargs) -> redis.commands.core.ResponseT

Enables read queries for a connection to a Redis Cluster replica node.

For more information see https://redis.io/commands/readonly

readwrite

readwrite(**kwargs) -> redis.commands.core.ResponseT

Disables read queries for a connection to a Redis Cluster slave node.

For more information see https://redis.io/commands/readwrite

register_script

register_script(
    script: redis.typing.ScriptTextT,
) -> redis.commands.core.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

renamenx(
    src: kvdb.types.generic.KeyT,
    dst: kvdb.types.generic.KeyT,
)

Rename key src to dst if dst doesn't already exist

For more information see https://redis.io/commands/renamenx

replicaof

replicaof(*args, **kwargs) -> redis.commands.core.ResponseT

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

reset

reset() -> None

Reset the state of the instance to when it was constructed

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

role() -> redis.commands.core.ResponseT

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

rpoplpush(
    src: str, dst: str
) -> typing.Union[typing.Awaitable[str], str]

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

rpush(
    name: str, *values: redis.typing.FieldT
) -> typing.Union[typing.Awaitable[int], int]

Push values onto the tail of the list name

For more information see https://redis.io/commands/rpush

rpushx

rpushx(
    name: str, *values: str
) -> typing.Union[typing.Awaitable[int], int]

Push value onto the tail of the list name if name exists

For more information see https://redis.io/commands/rpushx

sadd

sadd(
    name: str, *values: redis.typing.FieldT
) -> typing.Union[typing.Awaitable[int], int]

Add value(s) to set name

For more information see https://redis.io/commands/sadd

save

save(**kwargs) -> redis.commands.core.ResponseT

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

scard(
    name: str,
) -> typing.Union[typing.Awaitable[int], int]

Return the number of elements in set name

For more information see https://redis.io/commands/scard

script_exists

script_exists(*args: str) -> redis.commands.core.ResponseT

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

script_kill() -> redis.commands.core.ResponseT

Kill the currently executing Lua script

For more information see https://redis.io/commands/script-kill

script_load

script_load(
    script: redis.typing.ScriptTextT,
) -> redis.commands.core.ResponseT

Load a Lua script into the script cache. Returns the SHA.

For more information see https://redis.io/commands/script-load

sdiff

sdiff(
    keys: typing.List, *args: typing.List
) -> typing.Union[typing.Awaitable[list], list]

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(
    index: int, **kwargs
) -> redis.commands.core.ResponseT

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

setbit(
    name: kvdb.types.generic.KeyT, offset: int, value: int
) -> redis.commands.core.ResponseT

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

Source code in kvdb/components/session.py
def setitem(
    self,
    key: KeyT,
    value: Any,
    ex: Optional[ExpiryT] = None,
    **kwargs: Any,
) -> None:
    """
    [Dict] Sets the value for the given key
    """
    return self.persistence.set(key, value, ex = ex, **kwargs)

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

sinter(
    keys: typing.List, *args: typing.List
) -> typing.Union[typing.Awaitable[list], list]

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

slowlog_get(
    num: typing.Union[int, None] = None, **kwargs
) -> redis.commands.core.ResponseT

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

slowlog_len(**kwargs) -> redis.commands.core.ResponseT

Get the number of items in the slowlog

For more information see https://redis.io/commands/slowlog-len

slowlog_reset

slowlog_reset(**kwargs) -> redis.commands.core.ResponseT

Remove all items in the slowlog

For more information see https://redis.io/commands/slowlog-reset

smembers

smembers(
    name: str,
) -> typing.Union[typing.Awaitable[typing.Set], typing.Set]

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

smove(
    src: str, dst: str, value: str
) -> typing.Union[typing.Awaitable[bool], bool]

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

spop(
    name: str, count: typing.Optional[int] = None
) -> typing.Union[str, typing.List, None]

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

srem(
    name: str, *values: redis.typing.FieldT
) -> typing.Union[typing.Awaitable[int], int]

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

strlen(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

Return the number of bytes stored in the value of name

For more information see https://redis.io/commands/strlen

substr

substr(
    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.

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

swapdb(
    first: int, second: int, **kwargs
) -> redis.commands.core.ResponseT

Swap two databases

For more information see https://redis.io/commands/swapdb

sync

sync() -> redis.commands.core.ResponseT

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

tfunction_delete(
    lib_name: str,
) -> redis.commands.core.ResponseT

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

time(**kwargs) -> redis.commands.core.ResponseT

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

touch(
    *args: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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

ttl(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

Returns the number of seconds until the key name will expire

For more information see https://redis.io/commands/ttl

type

type(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

Returns the type of key name

For more information see https://redis.io/commands/type

unlink(
    *names: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

Unlink one or more keys specified by names

For more information see https://redis.io/commands/unlink

unwatch

unwatch() -> None

Unwatches the value at key name, or None of the key doesn't exist

For more information see https://redis.io/commands/unwatch

wait

wait(
    num_replicas: int, timeout: int, **kwargs
) -> redis.commands.core.ResponseT

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

watch(*names: kvdb.types.generic.KeyT) -> None

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

xinfo_groups(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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

xinfo_stream(
    name: kvdb.types.generic.KeyT, full: bool = False
) -> redis.commands.core.ResponseT

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

xlen(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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

zcard(
    name: kvdb.types.generic.KeyT,
) -> redis.commands.core.ResponseT

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

zdiff(
    keys: redis.typing.KeysT, withscores: bool = False
) -> redis.commands.core.ResponseT

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

zlexcount(name, min, max)

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

zmscore(
    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

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