Redis¶
The redis adapter provides a complete Redis integration including the concrete adapter, its abstract port interface,
index-bound RediSearch handles, and a mock implementation for testing.
Ports¶
Abstract port interface defining the Redis adapter contract.
Redis port interfaces composed from per-concern mixins.
archipy.adapters.redis.ports.RedisScoreCastType
module-attribute
¶
archipy.adapters.redis.ports.RedisPort ¶
Bases: RedisConnectionPort, RedisClusterPort, RedisKeysPort, RedisListsPort, RedisSetsPort, RedisSortedSetsPort, RedisArraysPort, RedisHashesPort, RedisPubSubPort
Interface for Redis operations providing a standardized access pattern.
Defines the contract for Redis adapters: key-value ops, collections (lists, sets, sorted sets, hashes), cluster admin, and pub/sub.
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.publish
abstractmethod
¶
Publishes a message to a channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
bytes | str
|
The channel to publish to. |
required |
message
|
bytes | str
|
The message to publish. |
required |
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of subscribers that received the message. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/pubsub.py
archipy.adapters.redis.ports.RedisPort.pubsub_channels
abstractmethod
¶
Lists active channels matching a pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
bytes | str
|
The pattern to match channels. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str]
|
A list of active channels. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/pubsub.py
archipy.adapters.redis.ports.RedisPort.pubsub
abstractmethod
¶
Returns a pub/sub object for subscribing to channels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
A pub/sub object. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/pubsub.py
archipy.adapters.redis.ports.RedisPort.hdel
abstractmethod
¶
Deletes one or more fields from a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
*keys
|
str | bytes
|
Fields to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The number of fields deleted. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.RedisPort.hexists
abstractmethod
¶
Checks if a field exists in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
key
|
str
|
The field to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the field exists, False otherwise. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.RedisPort.hget
abstractmethod
¶
Gets the value of a field in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
key
|
str
|
The field to get. |
required |
Returns:
| Type | Description |
|---|---|
bytes | str | None
|
str | None: The value of the field, or None if not found. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.RedisPort.hgetall
abstractmethod
¶
Gets all fields and values in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
Returns:
| Type | Description |
|---|---|
dict[bytes | str, bytes | str]
|
dict[str, Any]: A dictionary of field/value pairs. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.RedisPort.hkeys
abstractmethod
¶
Gets all fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
A list of fields in the hash. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.RedisPort.hlen
abstractmethod
¶
Gets the number of fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The number of fields in the hash. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.RedisPort.hset
abstractmethod
¶
hset(
name: str,
key: str | bytes | None = None,
value: str | bytes | None = None,
mapping: dict | None = None,
items: list | None = None,
) -> int
Sets one or more fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
key
|
str | bytes
|
A single field to set. |
None
|
value
|
str | bytes
|
The value for the single field. |
None
|
mapping
|
dict
|
A dictionary of field/value pairs. |
None
|
items
|
list
|
A list of field/value pairs. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The number of fields added or updated. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.RedisPort.hmget
abstractmethod
¶
Gets the values of multiple fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
keys
|
list
|
A list of fields to get. |
required |
*args
|
str | bytes
|
Additional fields to get. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str | None]
|
A list of values for the specified fields. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.RedisPort.hvals
abstractmethod
¶
Gets all values in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
A list of values in the hash. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.RedisPort.arset
abstractmethod
¶
Sets one or more contiguous values in the array stored at a key.
Values are stored at consecutive indices beginning at index in the Redis 8.8 array data
structure, an index-addressable, sparse-friendly container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
index
|
int
|
The starting index (0 to 2**64-1) to set values at. |
required |
*values
|
bytes | str | float
|
The values to store at consecutive indices. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of previously empty slots that were set. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/arrays.py
archipy.adapters.redis.ports.RedisPort.arget
abstractmethod
¶
Gets the value at an index in the array stored at a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
index
|
int
|
The index to read. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value at the index, or None if unset or the key doesn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/arrays.py
archipy.adapters.redis.ports.RedisPort.arlen
abstractmethod
¶
Gets the number of populated elements in an array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of populated elements. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/arrays.py
archipy.adapters.redis.ports.RedisPort.ardel
abstractmethod
¶
Deletes one or more indices from an array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
*indices
|
int
|
The indices to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of elements deleted. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/arrays.py
archipy.adapters.redis.ports.RedisPort.arring
abstractmethod
¶
Inserts values into an array as a fixed-size ring buffer (sliding window).
Each value is placed at insert_idx % size, wrapping back to index 0 and overwriting
older values once full, in a single atomic operation equivalent to RPUSH + LTRIM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
size
|
int
|
The fixed size of the ring buffer. |
required |
*values
|
bytes | str | float
|
The values to insert. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The last index where a value was inserted. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/arrays.py
archipy.adapters.redis.ports.RedisPort.zadd
abstractmethod
¶
zadd(
name: bytes | str,
mapping: Mapping[bytes | str, bytes | str | float],
nx: bool = False,
xx: bool = False,
ch: bool = False,
incr: bool = False,
gt: bool = False,
lt: bool = False,
) -> int | float | None
Adds members with scores to a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
mapping
|
Mapping[bytes | str, bytes | str | float]
|
A mapping of members to scores. |
required |
nx
|
bool
|
If True, only add new elements. Defaults to False. |
False
|
xx
|
bool
|
If True, only update existing elements. Defaults to False. |
False
|
ch
|
bool
|
If True, return the number of changed elements. Defaults to False. |
False
|
incr
|
bool
|
If True, increment scores instead of setting. Defaults to False. |
False
|
gt
|
bool
|
If True, only update if new score is greater. Defaults to False. |
False
|
lt
|
bool
|
If True, only update if new score is less. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int | float | None
|
The number of elements added or updated. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.RedisPort.zcard
abstractmethod
¶
Gets the number of members in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The cardinality (size) of the sorted set. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.RedisPort.zcount
abstractmethod
¶
Counts members in a sorted set within a score range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
min_
|
float | str
|
The minimum score (inclusive). |
required |
max_
|
float | str
|
The maximum score (inclusive). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of members within the score range. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.RedisPort.zpopmax
abstractmethod
¶
zpopmax(
name: bytes | str, count: int | None = None
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Removes and returns members with the highest scores from a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
count
|
int
|
Number of members to pop. Defaults to None (pops 1). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
A list of (member, score) tuples popped. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.RedisPort.zpopmin
abstractmethod
¶
zpopmin(
name: bytes | str, count: int | None = None
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Removes and returns members with the lowest scores from a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
count
|
int
|
Number of members to pop. Defaults to None (pops 1). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
A list of (member, score) tuples popped. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.RedisPort.zrange
abstractmethod
¶
zrange(
name: bytes | str,
start: int,
end: int,
desc: bool = False,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
byscore: bool = False,
bylex: bool = False,
offset: int | None = None,
num: int | None = None,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Gets a range of members from a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
start
|
int
|
The starting index or score (depending on byscore). |
required |
end
|
int
|
The ending index or score (depending on byscore). |
required |
desc
|
bool
|
If True, sort in descending order. Defaults to False. |
False
|
withscores
|
bool
|
If True, return scores with members. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
byscore
|
bool
|
If True, range by score instead of rank. Defaults to False. |
False
|
bylex
|
bool
|
If True, range by lexicographical order. Defaults to False. |
False
|
offset
|
int
|
Offset for byscore or bylex. |
None
|
num
|
int
|
Number of elements for byscore or bylex. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
A list of members (and scores if withscores=True). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.RedisPort.zrevrange
abstractmethod
¶
zrevrange(
name: bytes | str,
start: int,
end: int,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Gets a range of members from a sorted set in reverse order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
start
|
int
|
The starting index. |
required |
end
|
int
|
The ending index. |
required |
withscores
|
bool
|
If True, return scores with members. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
A list of members (and scores if withscores=True). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.RedisPort.zrangebyscore
abstractmethod
¶
zrangebyscore(
name: bytes | str,
min_: float | str,
max_: float | str,
start: int | None = None,
num: int | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Gets members from a sorted set by score range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
min_
|
float | str
|
The minimum score (inclusive). |
required |
max_
|
float | str
|
The maximum score (inclusive). |
required |
start
|
int
|
Starting offset. |
None
|
num
|
int
|
Number of elements to return. |
None
|
withscores
|
bool
|
If True, return scores with members. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
A list of members (and scores if withscores=True). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.RedisPort.zrank
abstractmethod
¶
Gets the rank of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
value
|
bytes | str | float
|
The member to find. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int | list[Any] | None
|
The rank (index) of the member, or None if not found. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.RedisPort.zrem
abstractmethod
¶
Removes one or more members from a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of members removed. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.RedisPort.zscore
abstractmethod
¶
Gets the score of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
value
|
bytes | str | float
|
The member to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
float | None
|
The score of the member, or None if not found. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.RedisPort.zunion
abstractmethod
¶
zunion(
keys: Mapping[bytes | str, float]
| Iterable[bytes | str],
aggregate: str | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Computes the union of multiple sorted sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Mapping[bytes | str, float] | Iterable[bytes | str]
|
Sorted set keys, optionally mapped to per-set weights. |
required |
aggregate
|
str
|
How to combine scores across sets: "SUM", "MIN", "MAX", or the Redis 8.8 "COUNT" aggregator, which scores each element by the number of input sets containing it (or the sum of their weights, if weights are given). Defaults to "SUM". |
None
|
withscores
|
bool
|
If True, return scores with members. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
A list of members (and scores if withscores=True). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.RedisPort.zinter
abstractmethod
¶
zinter(
keys: Mapping[bytes | str, float]
| Iterable[bytes | str],
aggregate: str | None = None,
withscores: bool = False,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Computes the intersection of multiple sorted sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Mapping[bytes | str, float] | Iterable[bytes | str]
|
Sorted set keys, optionally mapped to per-set weights. |
required |
aggregate
|
str
|
How to combine scores across sets: "SUM", "MIN", "MAX", or the Redis 8.8 "COUNT" aggregator, which scores each element by the number of input sets containing it (or the sum of their weights, if weights are given). Defaults to "SUM". |
None
|
withscores
|
bool
|
If True, return scores with members. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
A list of members (and scores if withscores=True). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.RedisPort.zincrby
abstractmethod
¶
Increments the score of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
amount
|
float
|
The amount to increment by. |
required |
value
|
bytes | str | float
|
The member to increment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
float | None
|
The new score of the member. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.RedisPort.sscan
abstractmethod
¶
sscan(
name: bytes | str,
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
) -> tuple[int, list[bytes | str]]
Iterates over members of a set incrementally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the set. |
required |
cursor
|
int
|
The cursor position to start scanning. Defaults to 0. |
0
|
match
|
bytes | str
|
Pattern to match members against. |
None
|
count
|
int
|
Hint for number of members to return per iteration. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
tuple[int, list[bytes | str]]
|
A tuple of (new_cursor, list_of_members). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.RedisPort.sscan_iter
abstractmethod
¶
sscan_iter(
name: bytes | str,
match: bytes | str | None = None,
count: int | None = None,
) -> Iterator[bytes | str]
Provides an iterator over members of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the set. |
required |
match
|
bytes | str
|
Pattern to match members against. |
None
|
count
|
int
|
Hint for number of members to return per iteration. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator[bytes | str]
|
An iterator yielding set members. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.RedisPort.sadd
abstractmethod
¶
Adds one or more members to a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
*values
|
bytes | str | float
|
Members to add. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The number of members added (excluding duplicates). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.RedisPort.scard
abstractmethod
¶
Gets the number of members in a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The cardinality (size) of the set. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.RedisPort.sismember
abstractmethod
¶
Checks if a value is a member of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
value
|
str
|
The value to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the value is a member, False otherwise. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.RedisPort.smembers
abstractmethod
¶
Gets all members of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
_set[bytes | str]
|
A set of all members. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.RedisPort.spop
abstractmethod
¶
Removes and returns one or more random members from a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
count
|
int
|
Number of members to pop. Defaults to None (pops 1). |
None
|
Returns:
| Type | Description |
|---|---|
bytes | float | int | str | list | None
|
bytes | float | int | str | list | None: The popped member(s), or None if the set is empty. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.RedisPort.srem
abstractmethod
¶
Removes one or more members from a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The number of members removed. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.RedisPort.sunion
abstractmethod
¶
Gets the union of multiple sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
bytes | str
|
Name of the first key. |
required |
*args
|
bytes | str
|
Additional key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
_set[bytes | str]
|
A set containing members of the resulting union. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.RedisPort.llen
abstractmethod
¶
Gets the length of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The number of items in the list. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/lists.py
archipy.adapters.redis.ports.RedisPort.lpop
abstractmethod
¶
Removes and returns the first element(s) of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
count
|
int
|
Number of elements to pop. Defaults to None (pops 1). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
bytes | str | list[bytes | str] | None
|
The popped element(s), or None if the list is empty. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/lists.py
archipy.adapters.redis.ports.RedisPort.lpush
abstractmethod
¶
Pushes one or more values to the start of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The length of the list after the push. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/lists.py
archipy.adapters.redis.ports.RedisPort.lrange
abstractmethod
¶
Gets a range of elements from a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
start
|
int
|
The starting index (inclusive). |
required |
end
|
int
|
The ending index (inclusive). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
A list of elements in the specified range. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/lists.py
archipy.adapters.redis.ports.RedisPort.lrem
abstractmethod
¶
Removes occurrences of a value from a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
count
|
int
|
Number of occurrences to remove (0 for all). |
required |
value
|
str
|
The value to remove. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The number of elements removed. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/lists.py
archipy.adapters.redis.ports.RedisPort.lset
abstractmethod
¶
Sets the value of an element in a list by index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
index
|
int
|
The index to set. |
required |
value
|
str
|
The new value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/lists.py
archipy.adapters.redis.ports.RedisPort.rpop
abstractmethod
¶
Removes and returns the last element(s) of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
count
|
int
|
Number of elements to pop. Defaults to None (pops 1). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
bytes | str | list[bytes | str] | None
|
The popped element(s), or None if the list is empty. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/lists.py
archipy.adapters.redis.ports.RedisPort.rpush
abstractmethod
¶
Pushes one or more values to the end of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The length of the list after the push. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/lists.py
archipy.adapters.redis.ports.RedisPort.pttl
abstractmethod
¶
Gets the remaining time to live of a key in milliseconds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The time to live in milliseconds, or -1 if no TTL, -2 if key doesn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.RedisPort.incrby
abstractmethod
¶
Increments the integer value of a key by the given amount.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to increment. |
required |
amount
|
int
|
The amount to increment by. Defaults to 1. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The new value after incrementing. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.RedisPort.increx
abstractmethod
¶
increx(
name: bytes | str,
byfloat: float | None = None,
byint: int | None = None,
lbound: float | None = None,
ubound: float | None = None,
saturate: bool = False,
ex: int | timedelta | None = None,
px: int | timedelta | None = None,
exat: int | datetime | None = None,
pxat: int | datetime | None = None,
persist: bool = False,
enx: bool = False,
) -> list[Any]
Increments a windowed counter with bounds and expiration control (window counter rate limiter).
This wraps the Redis 8.8 INCREX command, a generalized form of INCR/INCRBY/
INCRBYFLOAT with added support for value bounds and conditional expiration, making it
suitable for implementing rate limiters directly on the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to increment. Created if it doesn't already exist. |
required |
byfloat
|
float
|
Increment amount as a float. Mutually exclusive with byint. |
None
|
byint
|
int
|
Increment amount as an int. Defaults to 1 if neither is set. |
None
|
lbound
|
float | int
|
Lower bound the resulting value must satisfy. |
None
|
ubound
|
float | int
|
Upper bound the resulting value must satisfy (token capacity). |
None
|
saturate
|
bool
|
If True, clamp out-of-bounds results to the bound instead of rejecting the request. Defaults to False. |
False
|
ex
|
int | timedelta
|
Expiration time in seconds. |
None
|
px
|
int | timedelta
|
Expiration time in milliseconds. |
None
|
exat
|
int | datetime
|
Absolute expiration time in seconds. |
None
|
pxat
|
int | datetime
|
Absolute expiration time in milliseconds. |
None
|
persist
|
bool
|
If True, remove any existing expiration. Defaults to False. |
False
|
enx
|
bool
|
If True, set the expiration only when the key does not already have one, preserving the window's original TTL. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[Any]
|
A two-element list of |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.RedisPort.set
abstractmethod
¶
set(
name: bytes | str,
value: bytes | str | float,
ex: int | timedelta | None = None,
px: int | timedelta | None = None,
nx: bool = False,
xx: bool = False,
keepttl: bool = False,
get: bool = False,
exat: int | datetime | None = None,
pxat: int | datetime | None = None,
) -> bool | str | bytes | None
Sets a key to a value with optional expiration and conditions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to set. |
required |
value
|
int | bytes | str | float
|
The value to set for the key. |
required |
ex
|
int | timedelta
|
Expiration time in seconds or timedelta. |
None
|
px
|
int | timedelta
|
Expiration time in milliseconds or timedelta. |
None
|
nx
|
bool
|
If True, set only if the key does not exist. Defaults to False. |
False
|
xx
|
bool
|
If True, set only if the key already exists. Defaults to False. |
False
|
keepttl
|
bool
|
If True, retain the existing TTL. Defaults to False. |
False
|
get
|
bool
|
If True, return the old value before setting. Defaults to False. |
False
|
exat
|
int | datetime
|
Absolute expiration time as Unix timestamp or datetime. |
None
|
pxat
|
int | datetime
|
Absolute expiration time in milliseconds or datetime. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool | str | bytes | None
|
The result of the operation, often "OK" or the old value if get=True. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.RedisPort.get
abstractmethod
¶
Retrieves the value of a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value associated with the key, or None if the key doesn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.RedisPort.mget
abstractmethod
¶
Gets the values of multiple keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
bytes | str | Iterable[bytes | str]
|
A single key or iterable of keys. |
required |
*args
|
bytes | str
|
Additional keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str | None]
|
A list of values corresponding to the keys. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.RedisPort.mset
abstractmethod
¶
Sets multiple keys to their respective values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mapping
|
Mapping[bytes | str, bytes | str | float]
|
A mapping of keys to values. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool
|
Typically "OK" on success. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.RedisPort.keys
abstractmethod
¶
Returns all keys matching a pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
bytes | str
|
The pattern to match keys against. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str]
|
A list of matching keys. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.RedisPort.getset
abstractmethod
¶
Sets a key to a value and returns its old value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key to set. |
required |
value
|
bytes | str | float
|
The new value to set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The old value of the key, or None if it didn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.RedisPort.getdel
abstractmethod
¶
Gets the value of a key and deletes it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key to get and delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value of the key before deletion, or None if it didn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.RedisPort.exists
abstractmethod
¶
Checks if one or more keys exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of keys to check. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of keys that exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.RedisPort.delete
abstractmethod
¶
Deletes one or more keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of keys to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of keys deleted. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.RedisPort.append
abstractmethod
¶
Appends a value to a key's string value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key to append to. |
required |
value
|
bytes | str | float
|
The value to append. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The length of the string after appending. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.RedisPort.ttl
abstractmethod
¶
Gets the remaining time to live of a key in seconds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The time to live in seconds, or -1 if no TTL, -2 if key doesn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.RedisPort.type
abstractmethod
¶
Determines the type of value stored at a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str
|
The type of the key's value (e.g., "string", "list", etc.). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.RedisPort.scan
abstractmethod
¶
scan(
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> tuple[int, list[bytes | str]]
Iterates over keys in the database incrementally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cursor
|
int
|
The cursor position to start scanning. Defaults to 0. |
0
|
match
|
bytes | str
|
Pattern to match keys against. |
None
|
count
|
int
|
Hint for number of keys to return per iteration. |
None
|
_type
|
str
|
Filter by type (e.g., "string", "list"). |
None
|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
tuple[int, list[bytes | str]]
|
A tuple of (new_cursor, list_of_keys). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.RedisPort.scan_iter
abstractmethod
¶
scan_iter(
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> Iterator[bytes | str]
Provides an iterator over keys in the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match
|
bytes | str
|
Pattern to match keys against. |
None
|
count
|
int
|
Hint for number of keys to return per iteration. |
None
|
_type
|
str
|
Filter by type (e.g., "string", "list"). |
None
|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator[bytes | str]
|
An iterator yielding keys. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.RedisPort.cluster_info ¶
Get cluster information.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
dict[str, str] | None
|
Cluster information or None for standalone mode. |
archipy.adapters.redis.ports.RedisPort.cluster_nodes ¶
cluster_nodes() -> (
dict[
str,
dict[
str,
str
| bool
| list[list[str]]
| list[dict[str, str]],
],
]
| None
)
Get cluster nodes information.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
dict[str, dict[str, str | bool | list[list[str]] | list[dict[str, str]]]] | None
|
Cluster nodes info or None for standalone mode. |
Source code in archipy/adapters/redis/port_mixins/cluster.py
archipy.adapters.redis.ports.RedisPort.cluster_slots ¶
Get cluster slots mapping.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[Any] | None
|
Slots mapping or None for standalone mode. |
archipy.adapters.redis.ports.RedisPort.cluster_key_slot ¶
Get the hash slot for a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to get slot for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int | None
|
Key slot or None for standalone mode. |
archipy.adapters.redis.ports.RedisPort.cluster_count_keys_in_slot ¶
Count keys in a specific slot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slot
|
int
|
The slot number. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int | None
|
Key count or None for standalone mode. |
Source code in archipy/adapters/redis/port_mixins/cluster.py
archipy.adapters.redis.ports.RedisPort.cluster_get_keys_in_slot ¶
Get keys in a specific slot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slot
|
int
|
The slot number. |
required |
count
|
int
|
Maximum number of keys to return. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | None
|
List of keys or None for standalone mode. |
Source code in archipy/adapters/redis/port_mixins/cluster.py
archipy.adapters.redis.ports.RedisPort.ping
abstractmethod
¶
Tests the connection to the Redis server.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool
|
The response from the server, typically "PONG". |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/connection.py
archipy.adapters.redis.ports.RedisPort.flushdb
abstractmethod
¶
Delete all keys in the current database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asynchronous
|
bool
|
Whether Redis should flush asynchronously. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/connection.py
archipy.adapters.redis.ports.RedisPort.get_pipeline
abstractmethod
¶
Returns a pipeline object for batching commands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transaction
|
Any
|
If True, execute commands in a transaction. Defaults to True. |
True
|
shard_hint
|
Any
|
Hint for sharding in clustered Redis. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
A pipeline object. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/connection.py
archipy.adapters.redis.ports.RedisPort.config_set
abstractmethod
¶
Sets a Redis server configuration parameter.
Commonly used to enable keyspace/subkey notifications via notify-keyspace-events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The configuration parameter name. |
required |
value
|
str
|
The value to set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/connection.py
archipy.adapters.redis.ports.RedisPort.config_get
abstractmethod
¶
Gets Redis server configuration parameters matching a pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
str
|
Pattern to match configuration parameter names. Defaults to "*". |
'*'
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
dict[str, str]
|
A dictionary of configuration parameter names to values. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/connection.py
archipy.adapters.redis.ports.RedisPort.search_index
abstractmethod
¶
Return an index-bound RediSearch handle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
RediSearch index name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisSearchHandlePort |
RedisSearchHandlePort
|
Handle for index-scoped RediSearch operations. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/connection.py
archipy.adapters.redis.ports.AsyncRedisPort ¶
Bases: AsyncRedisConnectionPort, AsyncRedisClusterPort, AsyncRedisKeysPort, AsyncRedisListsPort, AsyncRedisSetsPort, AsyncRedisSortedSetsPort, AsyncRedisArraysPort, AsyncRedisHashesPort, AsyncRedisPubSubPort
Async interface for Redis operations providing a standardized access pattern.
Async counterpart of RedisPort: same surface, async methods throughout.
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.publish
abstractmethod
async
¶
Publishes a message to a channel asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
bytes | str
|
The channel to publish to. |
required |
message
|
bytes | str
|
The message to publish. |
required |
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of subscribers that received the message. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/pubsub.py
archipy.adapters.redis.ports.AsyncRedisPort.pubsub_channels
abstractmethod
async
¶
Lists active channels matching a pattern asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
bytes | str
|
The pattern to match channels. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str]
|
A list of active channels. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/pubsub.py
archipy.adapters.redis.ports.AsyncRedisPort.pubsub
abstractmethod
async
¶
Returns a pub/sub object for subscribing to channels asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
A pub/sub object. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/pubsub.py
archipy.adapters.redis.ports.AsyncRedisPort.hdel
abstractmethod
async
¶
Deletes one or more fields from a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
*keys
|
str | bytes
|
Fields to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The number of fields deleted. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.AsyncRedisPort.hexists
abstractmethod
async
¶
Checks if a field exists in a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
key
|
str
|
The field to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the field exists, False otherwise. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.AsyncRedisPort.hget
abstractmethod
async
¶
Gets the value of a field in a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
key
|
str
|
The field to get. |
required |
Returns:
| Type | Description |
|---|---|
bytes | str | None
|
str | None: The value of the field, or None if not found. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.AsyncRedisPort.hgetall
abstractmethod
async
¶
Gets all fields and values in a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
Returns:
| Type | Description |
|---|---|
dict[bytes | str, bytes | str]
|
dict[str, Any]: A dictionary of field/value pairs. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.AsyncRedisPort.hkeys
abstractmethod
async
¶
Gets all fields in a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
A list of fields in the hash. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.AsyncRedisPort.hlen
abstractmethod
async
¶
Gets the number of fields in a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The number of fields in the hash. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.AsyncRedisPort.hset
abstractmethod
async
¶
hset(
name: str,
key: str | bytes | None = None,
value: str | bytes | None = None,
mapping: dict | None = None,
items: list | None = None,
) -> int
Sets one or more fields in a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
key
|
str | bytes
|
A single field to set. |
None
|
value
|
str | bytes
|
The value for the single field. |
None
|
mapping
|
dict
|
A dictionary of field/value pairs. |
None
|
items
|
list
|
A list of field/value pairs. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The number of fields added or updated. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.AsyncRedisPort.hmget
abstractmethod
async
¶
Gets the values of multiple fields in a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
keys
|
list
|
A list of fields to get. |
required |
*args
|
str | bytes
|
Additional fields to get. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str | None]
|
A list of values for the specified fields. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.AsyncRedisPort.hvals
abstractmethod
async
¶
Gets all values in a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
A list of values in the hash. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/hashes.py
archipy.adapters.redis.ports.AsyncRedisPort.arset
abstractmethod
async
¶
Sets one or more contiguous values in the array stored at a key asynchronously.
Values are stored at consecutive indices beginning at index in the Redis 8.8 array data
structure, an index-addressable, sparse-friendly container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
index
|
int
|
The starting index (0 to 2**64-1) to set values at. |
required |
*values
|
bytes | str | float
|
The values to store at consecutive indices. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of previously empty slots that were set. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/arrays.py
archipy.adapters.redis.ports.AsyncRedisPort.arget
abstractmethod
async
¶
Gets the value at an index in the array stored at a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
index
|
int
|
The index to read. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value at the index, or None if unset or the key doesn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/arrays.py
archipy.adapters.redis.ports.AsyncRedisPort.arlen
abstractmethod
async
¶
Gets the number of populated elements in an array asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of populated elements. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/arrays.py
archipy.adapters.redis.ports.AsyncRedisPort.ardel
abstractmethod
async
¶
Deletes one or more indices from an array asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
*indices
|
int
|
The indices to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of elements deleted. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/arrays.py
archipy.adapters.redis.ports.AsyncRedisPort.arring
abstractmethod
async
¶
Inserts values into an array as a fixed-size ring buffer (sliding window) asynchronously.
Each value is placed at insert_idx % size, wrapping back to index 0 and overwriting
older values once full, in a single atomic operation equivalent to RPUSH + LTRIM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
size
|
int
|
The fixed size of the ring buffer. |
required |
*values
|
bytes | str | float
|
The values to insert. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The last index where a value was inserted. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/arrays.py
archipy.adapters.redis.ports.AsyncRedisPort.zadd
abstractmethod
async
¶
zadd(
name: bytes | str,
mapping: Mapping[bytes | str, bytes | str | float],
nx: bool = False,
xx: bool = False,
ch: bool = False,
incr: bool = False,
gt: bool = False,
lt: bool = False,
) -> int | float | None
Adds members with scores to a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
mapping
|
Mapping[bytes | str, bytes | str | float]
|
A mapping of members to scores. |
required |
nx
|
bool
|
If True, only add new elements. Defaults to False. |
False
|
xx
|
bool
|
If True, only update existing elements. Defaults to False. |
False
|
ch
|
bool
|
If True, return the number of changed elements. Defaults to False. |
False
|
incr
|
bool
|
If True, increment scores instead of setting. Defaults to False. |
False
|
gt
|
bool
|
If True, only update if new score is greater. Defaults to False. |
False
|
lt
|
bool
|
If True, only update if new score is less. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int | float | None
|
The number of elements added or updated. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.AsyncRedisPort.zcard
abstractmethod
async
¶
Gets the number of members in a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The cardinality (size) of the sorted set. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.AsyncRedisPort.zcount
abstractmethod
async
¶
Counts members in a sorted set within a score range asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
min_
|
float | str
|
The minimum score (inclusive). |
required |
max_
|
float | str
|
The maximum score (inclusive). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of members within the score range. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.AsyncRedisPort.zpopmax
abstractmethod
async
¶
zpopmax(
name: bytes | str, count: int | None = None
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Removes and returns members with the highest scores from a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
count
|
int
|
Number of members to pop. Defaults to None (pops 1). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
A list of (member, score) tuples popped. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.AsyncRedisPort.zpopmin
abstractmethod
async
¶
zpopmin(
name: bytes | str, count: int | None = None
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Removes and returns members with the lowest scores from a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
count
|
int
|
Number of members to pop. Defaults to None (pops 1). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
A list of (member, score) tuples popped. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.AsyncRedisPort.zrange
abstractmethod
async
¶
zrange(
name: bytes | str,
start: int,
end: int,
desc: bool = False,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
byscore: bool = False,
bylex: bool = False,
offset: int | None = None,
num: int | None = None,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Gets a range of members from a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
start
|
int
|
The starting index or score (depending on byscore). |
required |
end
|
int
|
The ending index or score (depending on byscore). |
required |
desc
|
bool
|
If True, sort in descending order. Defaults to False. |
False
|
withscores
|
bool
|
If True, return scores with members. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
byscore
|
bool
|
If True, range by score instead of rank. Defaults to False. |
False
|
bylex
|
bool
|
If True, range by lexicographical order. Defaults to False. |
False
|
offset
|
int
|
Offset for byscore or bylex. |
None
|
num
|
int
|
Number of elements for byscore or bylex. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
A list of members (and scores if withscores=True). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.AsyncRedisPort.zrevrange
abstractmethod
async
¶
zrevrange(
name: bytes | str,
start: int,
end: int,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Gets a range of members from a sorted set in reverse order asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
start
|
int
|
The starting index. |
required |
end
|
int
|
The ending index. |
required |
withscores
|
bool
|
If True, return scores with members. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
A list of members (and scores if withscores=True). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.AsyncRedisPort.zrangebyscore
abstractmethod
async
¶
zrangebyscore(
name: bytes | str,
min_: float | str,
max_: float | str,
start: int | None = None,
num: int | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Gets members from a sorted set by score range asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
min_
|
float | str
|
The minimum score (inclusive). |
required |
max_
|
float | str
|
The maximum score (inclusive). |
required |
start
|
int
|
Starting offset. |
None
|
num
|
int
|
Number of elements to return. |
None
|
withscores
|
bool
|
If True, return scores with members. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
A list of members (and scores if withscores=True). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.AsyncRedisPort.zrank
abstractmethod
async
¶
Gets the rank of a member in a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
value
|
bytes | str | float
|
The member to find. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int | list[Any] | None
|
The rank (index) of the member, or None if not found. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.AsyncRedisPort.zrem
abstractmethod
async
¶
Removes one or more members from a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of members removed. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.AsyncRedisPort.zscore
abstractmethod
async
¶
Gets the score of a member in a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
value
|
bytes | str | float
|
The member to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
float | None
|
The score of the member, or None if not found. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.AsyncRedisPort.zunion
abstractmethod
async
¶
zunion(
keys: Mapping[bytes | str, float]
| Iterable[bytes | str],
aggregate: str | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Computes the union of multiple sorted sets asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Mapping[bytes | str, float] | Iterable[bytes | str]
|
Sorted set keys, optionally mapped to per-set weights. |
required |
aggregate
|
str
|
How to combine scores across sets: "SUM", "MIN", "MAX", or the Redis 8.8 "COUNT" aggregator, which scores each element by the number of input sets containing it (or the sum of their weights, if weights are given). Defaults to "SUM". |
None
|
withscores
|
bool
|
If True, return scores with members. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
A list of members (and scores if withscores=True). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.AsyncRedisPort.zinter
abstractmethod
async
¶
zinter(
keys: Mapping[bytes | str, float]
| Iterable[bytes | str],
aggregate: str | None = None,
withscores: bool = False,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Computes the intersection of multiple sorted sets asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Mapping[bytes | str, float] | Iterable[bytes | str]
|
Sorted set keys, optionally mapped to per-set weights. |
required |
aggregate
|
str
|
How to combine scores across sets: "SUM", "MIN", "MAX", or the Redis 8.8 "COUNT" aggregator, which scores each element by the number of input sets containing it (or the sum of their weights, if weights are given). Defaults to "SUM". |
None
|
withscores
|
bool
|
If True, return scores with members. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
A list of members (and scores if withscores=True). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.AsyncRedisPort.zincrby
abstractmethod
async
¶
Increments the score of a member in a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
amount
|
float
|
The amount to increment by. |
required |
value
|
bytes | str | float
|
The member to increment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
float | None
|
The new score of the member. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sorted_sets.py
archipy.adapters.redis.ports.AsyncRedisPort.sscan
abstractmethod
async
¶
sscan(
name: bytes | str,
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
) -> tuple[int, list[bytes | str]]
Iterates over members of a set incrementally asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the set. |
required |
cursor
|
int
|
The cursor position to start scanning. Defaults to 0. |
0
|
match
|
bytes | str
|
Pattern to match members against. |
None
|
count
|
int
|
Hint for number of members to return per iteration. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
tuple[int, list[bytes | str]]
|
A tuple of (new_cursor, list_of_members). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.AsyncRedisPort.sscan_iter
abstractmethod
async
¶
sscan_iter(
name: bytes | str,
match: bytes | str | None = None,
count: int | None = None,
) -> AsyncIterator[bytes | str]
Provides an iterator over members of a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the set. |
required |
match
|
bytes | str
|
Pattern to match members against. |
None
|
count
|
int
|
Hint for number of members to return per iteration. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
AsyncIterator[bytes | str]
|
An iterator yielding set members. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.AsyncRedisPort.sadd
abstractmethod
async
¶
Adds one or more members to a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
*values
|
bytes | str | float
|
Members to add. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The number of members added (excluding duplicates). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.AsyncRedisPort.scard
abstractmethod
async
¶
Gets the number of members in a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The cardinality (size) of the set. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.AsyncRedisPort.sismember
abstractmethod
async
¶
Checks if a value is a member of a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
value
|
str
|
The value to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the value is a member, False otherwise. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.AsyncRedisPort.smembers
abstractmethod
async
¶
Gets all members of a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
_set[bytes | str]
|
A set of all members. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.AsyncRedisPort.spop
abstractmethod
async
¶
Removes and returns one or more random members from a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
count
|
int
|
Number of members to pop. Defaults to None (pops 1). |
None
|
Returns:
| Type | Description |
|---|---|
bytes | float | int | str | list | None
|
bytes | float | int | str | list | None: The popped member(s), or None if the set is empty. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.AsyncRedisPort.srem
abstractmethod
async
¶
Removes one or more members from a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The number of members removed. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.AsyncRedisPort.sunion
abstractmethod
async
¶
Gets the union of multiple sets asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
bytes | str
|
Name of the first key. |
required |
*args
|
bytes | str
|
Additional key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
_set[bytes | str]
|
A set containing members of the resulting union. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/sets.py
archipy.adapters.redis.ports.AsyncRedisPort.llen
abstractmethod
async
¶
Gets the length of a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The number of items in the list. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/lists.py
archipy.adapters.redis.ports.AsyncRedisPort.lpop
abstractmethod
async
¶
Removes and returns the first element(s) of a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
count
|
int
|
Number of elements to pop. Defaults to None (pops 1). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
bytes | str | list[bytes | str] | None
|
The popped element(s), or None if the list is empty. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/lists.py
archipy.adapters.redis.ports.AsyncRedisPort.lpush
abstractmethod
async
¶
Pushes one or more values to the start of a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The length of the list after the push. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/lists.py
archipy.adapters.redis.ports.AsyncRedisPort.lrange
abstractmethod
async
¶
Gets a range of elements from a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
start
|
int
|
The starting index (inclusive). |
required |
end
|
int
|
The ending index (inclusive). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
A list of elements in the specified range. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/lists.py
archipy.adapters.redis.ports.AsyncRedisPort.lrem
abstractmethod
async
¶
Removes occurrences of a value from a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
count
|
int
|
Number of occurrences to remove (0 for all). |
required |
value
|
str
|
The value to remove. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The number of elements removed. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/lists.py
archipy.adapters.redis.ports.AsyncRedisPort.lset
abstractmethod
async
¶
Sets the value of an element in a list by index asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
index
|
int
|
The index to set. |
required |
value
|
str
|
The new value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/lists.py
archipy.adapters.redis.ports.AsyncRedisPort.rpop
abstractmethod
async
¶
Removes and returns the last element(s) of a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
count
|
int
|
Number of elements to pop. Defaults to None (pops 1). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
bytes | str | list[bytes | str] | None
|
The popped element(s), or None if the list is empty. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/lists.py
archipy.adapters.redis.ports.AsyncRedisPort.rpush
abstractmethod
async
¶
Pushes one or more values to the end of a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
The length of the list after the push. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/lists.py
archipy.adapters.redis.ports.AsyncRedisPort.pttl
abstractmethod
async
¶
Gets the remaining time to live of a key in milliseconds asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The time to live in milliseconds, or -1 if no TTL, -2 if key doesn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.AsyncRedisPort.incrby
abstractmethod
async
¶
Increments the integer value of a key by the given amount asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to increment. |
required |
amount
|
int
|
The amount to increment by. Defaults to 1. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The new value after incrementing. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.AsyncRedisPort.increx
abstractmethod
async
¶
increx(
name: bytes | str,
byfloat: float | None = None,
byint: int | None = None,
lbound: float | None = None,
ubound: float | None = None,
saturate: bool = False,
ex: int | timedelta | None = None,
px: int | timedelta | None = None,
exat: int | datetime | None = None,
pxat: int | datetime | None = None,
persist: bool = False,
enx: bool = False,
) -> list[Any]
Increments a windowed counter with bounds and expiration control (window counter rate limiter).
This wraps the Redis 8.8 INCREX command, a generalized form of INCR/INCRBY/
INCRBYFLOAT with added support for value bounds and conditional expiration, making it
suitable for implementing rate limiters directly on the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to increment. Created if it doesn't already exist. |
required |
byfloat
|
float
|
Increment amount as a float. Mutually exclusive with byint. |
None
|
byint
|
int
|
Increment amount as an int. Defaults to 1 if neither is set. |
None
|
lbound
|
float | int
|
Lower bound the resulting value must satisfy. |
None
|
ubound
|
float | int
|
Upper bound the resulting value must satisfy (token capacity). |
None
|
saturate
|
bool
|
If True, clamp out-of-bounds results to the bound instead of rejecting the request. Defaults to False. |
False
|
ex
|
int | timedelta
|
Expiration time in seconds. |
None
|
px
|
int | timedelta
|
Expiration time in milliseconds. |
None
|
exat
|
int | datetime
|
Absolute expiration time in seconds. |
None
|
pxat
|
int | datetime
|
Absolute expiration time in milliseconds. |
None
|
persist
|
bool
|
If True, remove any existing expiration. Defaults to False. |
False
|
enx
|
bool
|
If True, set the expiration only when the key does not already have one, preserving the window's original TTL. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[Any]
|
A two-element list of |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.AsyncRedisPort.set
abstractmethod
async
¶
set(
name: bytes | str,
value: bytes | str | float,
ex: int | timedelta | None = None,
px: int | timedelta | None = None,
nx: bool = False,
xx: bool = False,
keepttl: bool = False,
get: bool = False,
exat: int | datetime | None = None,
pxat: int | datetime | None = None,
) -> bool | str | bytes | None
Sets a key to a value with optional expiration and conditions asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to set. |
required |
value
|
int | bytes | str | float
|
The value to set for the key. |
required |
ex
|
int | timedelta
|
Expiration time in seconds or timedelta. |
None
|
px
|
int | timedelta
|
Expiration time in milliseconds or timedelta. |
None
|
nx
|
bool
|
If True, set only if the key does not exist. Defaults to False. |
False
|
xx
|
bool
|
If True, set only if the key already exists. Defaults to False. |
False
|
keepttl
|
bool
|
If True, retain the existing TTL. Defaults to False. |
False
|
get
|
bool
|
If True, return the old value before setting. Defaults to False. |
False
|
exat
|
int | datetime
|
Absolute expiration time as Unix timestamp or datetime. |
None
|
pxat
|
int | datetime
|
Absolute expiration time in milliseconds or datetime. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool | str | bytes | None
|
The result of the operation, often "OK" or the old value if get=True. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.AsyncRedisPort.get
abstractmethod
async
¶
Retrieves the value of a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value associated with the key, or None if the key doesn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.AsyncRedisPort.mget
abstractmethod
async
¶
Gets the values of multiple keys asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
bytes | str | Iterable[bytes | str]
|
A single key or iterable of keys. |
required |
*args
|
bytes | str
|
Additional keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str | None]
|
A list of values corresponding to the keys. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.AsyncRedisPort.mset
abstractmethod
async
¶
Sets multiple keys to their respective values asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mapping
|
Mapping[bytes | str, bytes | str | float]
|
A mapping of keys to values. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool
|
Typically "OK" on success. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.AsyncRedisPort.keys
abstractmethod
async
¶
Returns all keys matching a pattern asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
bytes | str
|
The pattern to match keys against. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str]
|
A list of matching keys. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.AsyncRedisPort.getset
abstractmethod
async
¶
Sets a key to a value and returns its old value asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key to set. |
required |
value
|
bytes | str | float
|
The new value to set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The old value of the key, or None if it didn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.AsyncRedisPort.getdel
abstractmethod
async
¶
Gets the value of a key and deletes it asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key to get and delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value of the key before deletion, or None if it didn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.AsyncRedisPort.exists
abstractmethod
async
¶
Checks if one or more keys exist asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of keys to check. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of keys that exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.AsyncRedisPort.delete
abstractmethod
async
¶
Deletes one or more keys asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of keys to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of keys deleted. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.AsyncRedisPort.append
abstractmethod
async
¶
Appends a value to a key's string value asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key to append to. |
required |
value
|
bytes | str | float
|
The value to append. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The length of the string after appending. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.AsyncRedisPort.ttl
abstractmethod
async
¶
Gets the remaining time to live of a key in seconds asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The time to live in seconds, or -1 if no TTL, -2 if key doesn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.AsyncRedisPort.type
abstractmethod
async
¶
Determines the type of value stored at a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str
|
The type of the key's value (e.g., "string", "list", etc.). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.AsyncRedisPort.scan
abstractmethod
async
¶
scan(
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> tuple[int, list[bytes | str]]
Iterates over keys in the database incrementally asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cursor
|
int
|
The cursor position to start scanning. Defaults to 0. |
0
|
match
|
bytes | str
|
Pattern to match keys against. |
None
|
count
|
int
|
Hint for number of keys to return per iteration. |
None
|
_type
|
str
|
Filter by type (e.g., "string", "list"). |
None
|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
tuple[int, list[bytes | str]]
|
A tuple of (new_cursor, list_of_keys). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.AsyncRedisPort.scan_iter
abstractmethod
async
¶
scan_iter(
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> AsyncIterator[bytes | str]
Provides an iterator over keys in the database asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match
|
bytes | str
|
Pattern to match keys against. |
None
|
count
|
int
|
Hint for number of keys to return per iteration. |
None
|
_type
|
str
|
Filter by type (e.g., "string", "list"). |
None
|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
AsyncIterator[bytes | str]
|
An iterator yielding keys. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/keys.py
archipy.adapters.redis.ports.AsyncRedisPort.cluster_info
async
¶
Get cluster information asynchronously.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
dict[str, str] | None
|
Cluster information or None for standalone mode. |
archipy.adapters.redis.ports.AsyncRedisPort.cluster_nodes
async
¶
cluster_nodes() -> (
dict[
str,
dict[
str,
str
| bool
| list[list[str]]
| list[dict[str, str]],
],
]
| None
)
Get cluster nodes information asynchronously.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
dict[str, dict[str, str | bool | list[list[str]] | list[dict[str, str]]]] | None
|
Cluster nodes info or None for standalone mode. |
Source code in archipy/adapters/redis/port_mixins/cluster.py
archipy.adapters.redis.ports.AsyncRedisPort.cluster_slots
async
¶
Get cluster slots mapping asynchronously.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[Any] | None
|
Slots mapping or None for standalone mode. |
archipy.adapters.redis.ports.AsyncRedisPort.cluster_key_slot
async
¶
Get the hash slot for a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to get slot for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int | None
|
Key slot or None for standalone mode. |
Source code in archipy/adapters/redis/port_mixins/cluster.py
archipy.adapters.redis.ports.AsyncRedisPort.cluster_count_keys_in_slot
async
¶
Count keys in a specific slot asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slot
|
int
|
The slot number. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int | None
|
Key count or None for standalone mode. |
Source code in archipy/adapters/redis/port_mixins/cluster.py
archipy.adapters.redis.ports.AsyncRedisPort.cluster_get_keys_in_slot
async
¶
Get keys in a specific slot asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slot
|
int
|
The slot number. |
required |
count
|
int
|
Maximum number of keys to return. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | None
|
List of keys or None for standalone mode. |
Source code in archipy/adapters/redis/port_mixins/cluster.py
archipy.adapters.redis.ports.AsyncRedisPort.ping
abstractmethod
async
¶
Tests the connection to the Redis server asynchronously.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool
|
The response from the server, typically "PONG". |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/connection.py
archipy.adapters.redis.ports.AsyncRedisPort.flushdb
abstractmethod
async
¶
Delete all keys in the current database asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asynchronous
|
bool
|
Whether Redis should flush asynchronously. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/connection.py
archipy.adapters.redis.ports.AsyncRedisPort.get_pipeline
abstractmethod
async
¶
Returns a pipeline object for batching commands asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transaction
|
Any
|
If True, execute commands in a transaction. Defaults to True. |
True
|
shard_hint
|
Any
|
Hint for sharding in clustered Redis. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
A pipeline object. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/connection.py
archipy.adapters.redis.ports.AsyncRedisPort.config_set
abstractmethod
async
¶
Sets a Redis server configuration parameter asynchronously.
Commonly used to enable keyspace/subkey notifications via notify-keyspace-events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The configuration parameter name. |
required |
value
|
str
|
The value to set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/connection.py
archipy.adapters.redis.ports.AsyncRedisPort.config_get
abstractmethod
async
¶
Gets Redis server configuration parameters matching a pattern asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
str
|
Pattern to match configuration parameter names. Defaults to "*". |
'*'
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
dict[str, str]
|
A dictionary of configuration parameter names to values. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/connection.py
archipy.adapters.redis.ports.AsyncRedisPort.search_index
abstractmethod
¶
Return an index-bound async RediSearch handle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
RediSearch index name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AsyncRedisSearchHandlePort |
AsyncRedisSearchHandlePort
|
Handle for index-scoped async RediSearch operations. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/port_mixins/connection.py
options: show_root_toc_entry: false heading_level: 3
Adapters¶
Concrete Redis adapter wrapping the Redis client with ArchiPy conventions for cache operations, pub/sub, and key-value management.
Redis adapters composed from per-concern mixins.
archipy.adapters.redis.adapters.RedisAdapter ¶
Bases: RedisConnectionMixin, RedisClusterMixin, RedisKeysMixin, RedisListsMixin, RedisSetsMixin, RedisSortedSetsMixin, RedisArraysMixin, RedisHashesMixin, RedisPubSubMixin, RedisPort
Adapter for Redis operations providing a standardized interface.
Implements RedisPort over sync redis-py clients. Maintains separate read/write clients for replica-friendly deployments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
redis_config
|
RedisConfig | None
|
Redis settings. Uses global config when None. |
None
|
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.client
instance-attribute
¶
archipy.adapters.redis.adapters.RedisAdapter.read_only_client
instance-attribute
¶
archipy.adapters.redis.adapters.RedisAdapter.publish ¶
Publish a message to a channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
bytes | str
|
Channel name. |
required |
message
|
bytes | str
|
Message to publish. |
required |
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of subscribers that received the message. |
Source code in archipy/adapters/redis/adapter_mixins/pubsub.py
archipy.adapters.redis.adapters.RedisAdapter.pubsub_channels ¶
List active channels matching a pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
bytes | str
|
Pattern to match channels. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str]
|
List of channel names. |
Source code in archipy/adapters/redis/adapter_mixins/pubsub.py
archipy.adapters.redis.adapters.RedisAdapter.pubsub ¶
Get a PubSub object for subscribing to channels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
PubSub |
PubSub
|
PubSub object. |
Source code in archipy/adapters/redis/adapter_mixins/pubsub.py
archipy.adapters.redis.adapters.RedisAdapter.hdel ¶
Delete fields from a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
*keys
|
str | bytes
|
Fields to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of fields deleted. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.RedisAdapter.hexists ¶
Check if a field exists in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str
|
Field to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if field exists, False otherwise. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.RedisAdapter.hget ¶
Get the value of a field in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str
|
Field to get. |
required |
Returns:
| Type | Description |
|---|---|
bytes | str | None
|
str | None: Value of the field or None. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.RedisAdapter.hgetall ¶
Get all fields and values in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Type | Description |
|---|---|
dict[bytes | str, bytes | str]
|
dict[str, Any]: Dictionary of field-value pairs. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.RedisAdapter.hkeys ¶
Get all fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
List of field names. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.RedisAdapter.hlen ¶
Get the number of fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of fields. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.RedisAdapter.hset ¶
hset(
name: str,
key: str | bytes | None = None,
value: str | bytes | None = None,
mapping: dict | None = None,
items: list | None = None,
) -> int
Set fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str | bytes | None
|
Single field name. Defaults to None. |
None
|
value
|
str | bytes | None
|
Single field value. Defaults to None. |
None
|
mapping
|
dict | None
|
Dictionary of field-value pairs. Defaults to None. |
None
|
items
|
list | None
|
List of field-value pairs. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of fields set. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.RedisAdapter.hmget ¶
Get values of multiple fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
keys
|
list
|
List of field names. |
required |
*args
|
str | bytes
|
Additional field names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str | None]
|
List of field values. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.RedisAdapter.hvals ¶
Get all values in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
List of values. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.RedisAdapter.arset ¶
Set one or more contiguous values in an array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
index
|
int
|
The starting index to set values at. |
required |
*values
|
bytes | str | float
|
Values to store at consecutive indices. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of previously empty slots that were set. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.adapters.RedisAdapter.arget ¶
Get the value at an index in an array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
index
|
int
|
The index to read. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value at the index, or None if unset. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.adapters.RedisAdapter.arlen ¶
Get the number of populated elements in an array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of populated elements. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.adapters.RedisAdapter.ardel ¶
Delete one or more indices from an array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
*indices
|
int
|
Indices to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of elements deleted. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.adapters.RedisAdapter.arring ¶
Insert values into an array as a fixed-size ring buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
size
|
int
|
The fixed size of the ring buffer. |
required |
*values
|
bytes | str | float
|
Values to insert. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The last index where a value was inserted. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.adapters.RedisAdapter.zadd ¶
zadd(
name: bytes | str,
mapping: Mapping[bytes | str, bytes | str | float],
nx: bool = False,
xx: bool = False,
ch: bool = False,
incr: bool = False,
gt: bool = False,
lt: bool = False,
) -> int | float | None
Add members to a sorted set with scores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
mapping
|
Mapping[bytes | str, bytes | str | float]
|
Member-score pairs. |
required |
nx
|
bool
|
Only add new elements. Defaults to False. |
False
|
xx
|
bool
|
Only update existing elements. Defaults to False. |
False
|
ch
|
bool
|
Return number of changed elements. Defaults to False. |
False
|
incr
|
bool
|
Increment existing scores. Defaults to False. |
False
|
gt
|
bool
|
Only update if score is greater. Defaults to False. |
False
|
lt
|
bool
|
Only update if score is less. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int | float | None
|
Number of elements added or modified. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.RedisAdapter.zcard ¶
Get the number of members in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of members. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.RedisAdapter.zcount ¶
Count members in a sorted set with scores in range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
min_
|
float | str
|
Minimum score. |
required |
max_
|
float | str
|
Maximum score. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of members in range. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.RedisAdapter.zpopmax ¶
zpopmax(
name: bytes | str, count: int | None = None
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Remove and return members with highest scores from sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
count
|
int | None
|
Number of members to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of popped member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.RedisAdapter.zpopmin ¶
zpopmin(
name: bytes | str, count: int | None = None
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Remove and return members with lowest scores from sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
count
|
int | None
|
Number of members to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of popped member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.RedisAdapter.zrange ¶
zrange(
name: bytes | str,
start: int,
end: int,
desc: bool = False,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
byscore: bool = False,
bylex: bool = False,
offset: int | None = None,
num: int | None = None,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Get a range of members from a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
start
|
int
|
Start index or score. |
required |
end
|
int
|
End index or score. |
required |
desc
|
bool
|
Sort in descending order. Defaults to False. |
False
|
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
byscore
|
bool
|
Range by score. Defaults to False. |
False
|
bylex
|
bool
|
Range by lexicographical order. Defaults to False. |
False
|
offset
|
int | None
|
Offset for byscore/bylex. Defaults to None. |
None
|
num
|
int | None
|
Count for byscore/bylex. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.RedisAdapter.zrevrange ¶
zrevrange(
name: bytes | str,
start: int,
end: int,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Get a range of members from a sorted set in reverse order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
start
|
int
|
Start index. |
required |
end
|
int
|
End index. |
required |
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.RedisAdapter.zrangebyscore ¶
zrangebyscore(
name: bytes | str,
min_: float | str,
max_: float | str,
start: int | None = None,
num: int | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Get members from a sorted set by score range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
min_
|
float | str
|
Minimum score. |
required |
max_
|
float | str
|
Maximum score. |
required |
start
|
int | None
|
Offset. Defaults to None. |
None
|
num
|
int | None
|
Count. Defaults to None. |
None
|
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.RedisAdapter.zrank ¶
Get the rank of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
value
|
bytes | str | float
|
Member to find rank for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int | list[Any] | None
|
Rank of the member or None if not found. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.RedisAdapter.zrem ¶
Remove members from a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of members removed. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.RedisAdapter.zscore ¶
Get the score of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
value
|
bytes | str | float
|
Member to get score for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
float | None
|
Score of the member or None if not found. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.RedisAdapter.zunion ¶
zunion(
keys: Mapping[bytes | str, float]
| Iterable[bytes | str],
aggregate: str | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Compute the union of multiple sorted sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Mapping[bytes | str, float] | Iterable[bytes | str]
|
Sorted set keys, optionally mapped to per-set weights. |
required |
aggregate
|
str | None
|
"SUM", "MIN", "MAX", or "COUNT". Defaults to "SUM". |
None
|
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.RedisAdapter.zinter ¶
zinter(
keys: Mapping[bytes | str, float]
| Iterable[bytes | str],
aggregate: str | None = None,
withscores: bool = False,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Compute the intersection of multiple sorted sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Mapping[bytes | str, float] | Iterable[bytes | str]
|
Sorted set keys, optionally mapped to per-set weights. |
required |
aggregate
|
str | None
|
"SUM", "MIN", "MAX", or "COUNT". Defaults to "SUM". |
None
|
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.RedisAdapter.zincrby ¶
Increment the score of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
amount
|
float
|
Amount to increment by. |
required |
value
|
bytes | str | float
|
Member to increment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
float | None
|
New score of the member. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.RedisAdapter.sscan ¶
sscan(
name: bytes | str,
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
) -> tuple[int, list[bytes | str]]
Scan members of a set incrementally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The set key name. |
required |
cursor
|
int
|
Cursor position. Defaults to 0. |
0
|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of elements. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
tuple[int, list[bytes | str]]
|
Tuple of cursor and list of members. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.RedisAdapter.sscan_iter ¶
sscan_iter(
name: bytes | str,
match: bytes | str | None = None,
count: int | None = None,
) -> Iterator[bytes | str]
Iterate over members of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The set key name. |
required |
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of elements. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator[bytes | str]
|
Iterator over set members. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.RedisAdapter.sadd ¶
Add members to a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
*values
|
bytes | str | float
|
Members to add. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of elements added. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.RedisAdapter.scard ¶
Get the number of members in a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of members. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.RedisAdapter.sismember ¶
Check if a value is a member of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
value
|
str
|
Value to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if value is a member, False otherwise. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.RedisAdapter.smembers ¶
Get all members of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
_set[bytes | str]
|
Set of all members. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.RedisAdapter.spop ¶
Remove and return random members from a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
count
|
int | None
|
Number of members to pop. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
bytes | float | int | str | list | None
|
bytes | float | int | str | list | None: Popped member(s) or None. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.RedisAdapter.srem ¶
Remove members from a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of members removed. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.RedisAdapter.sunion ¶
Get the union of multiple sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
bytes | str
|
First set key. |
required |
*args
|
bytes | str
|
Additional set keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
_set[bytes | str]
|
Set containing union of all sets. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.RedisAdapter.llen ¶
Get the length of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Length of the list. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.adapters.RedisAdapter.lpop ¶
Remove and return elements from the left of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int | None
|
Number of elements to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
bytes | str | list[bytes | str] | None
|
Popped element(s) or None if list is empty. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.adapters.RedisAdapter.lpush ¶
Push elements to the left of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Length of the list after push. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.adapters.RedisAdapter.lrange ¶
Get a range of elements from a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
start
|
int
|
Start index. |
required |
end
|
int
|
End index. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
List of elements in the specified range. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.adapters.RedisAdapter.lrem ¶
Remove elements from a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int
|
Number of occurrences to remove. |
required |
value
|
str
|
Value to remove. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of elements removed. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.adapters.RedisAdapter.lset ¶
Set the value of an element in a list by its index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
index
|
int
|
Index of the element. |
required |
value
|
str
|
New value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.adapters.RedisAdapter.rpop ¶
Remove and return elements from the right of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int | None
|
Number of elements to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
bytes | str | list[bytes | str] | None
|
Popped element(s) or None if list is empty. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.adapters.RedisAdapter.rpush ¶
Push elements to the right of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Length of the list after push. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.adapters.RedisAdapter.pttl ¶
Get the time to live in milliseconds for a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Time to live in milliseconds. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.RedisAdapter.incrby ¶
Increment the integer value of a key by the given amount.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
amount
|
int
|
Amount to increment by. Defaults to 1. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The new value after increment. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.RedisAdapter.increx ¶
increx(
name: bytes | str,
byfloat: float | None = None,
byint: int | None = None,
lbound: float | None = None,
ubound: float | None = None,
saturate: bool = False,
ex: int | timedelta | None = None,
px: int | timedelta | None = None,
exat: int | datetime | None = None,
pxat: int | datetime | None = None,
persist: bool = False,
enx: bool = False,
) -> list[Any]
Increment a windowed counter with bounds and expiration control.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to increment. |
required |
byfloat
|
float
|
Increment amount as a float. |
None
|
byint
|
int
|
Increment amount as an int. |
None
|
lbound
|
float | int
|
Lower bound for the resulting value. |
None
|
ubound
|
float | int
|
Upper bound for the resulting value. |
None
|
saturate
|
bool
|
Clamp out-of-bounds results instead of rejecting. Defaults to False. |
False
|
ex
|
int | timedelta | None
|
Expire time in seconds. |
None
|
px
|
int | timedelta | None
|
Expire time in milliseconds. |
None
|
exat
|
int | datetime | None
|
Absolute expiration time in seconds. |
None
|
pxat
|
int | datetime | None
|
Absolute expiration time in milliseconds. |
None
|
persist
|
bool
|
Remove any existing expiration. Defaults to False. |
False
|
enx
|
bool
|
Set expiration only if none already exists. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[Any]
|
A two-element list of [new_value, actual_increment_applied]. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.RedisAdapter.set ¶
set(
name: bytes | str,
value: bytes | str | float,
ex: int | timedelta | None = None,
px: int | timedelta | None = None,
nx: bool = False,
xx: bool = False,
keepttl: bool = False,
get: bool = False,
exat: int | datetime | None = None,
pxat: int | datetime | None = None,
) -> bool | str | bytes | None
Set the value of a key with optional expiration and conditions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
value
|
int | bytes | str | float
|
The value to set. |
required |
ex
|
int | timedelta | None
|
Expire time in seconds. |
None
|
px
|
int | timedelta | None
|
Expire time in milliseconds. |
None
|
nx
|
bool
|
Only set if key doesn't exist. |
False
|
xx
|
bool
|
Only set if key exists. |
False
|
keepttl
|
bool
|
Retain the TTL from the previous value. |
False
|
get
|
bool
|
Return the old value. |
False
|
exat
|
int | datetime | None
|
Absolute expiration time in seconds. |
None
|
pxat
|
int | datetime | None
|
Absolute expiration time in milliseconds. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool | str | bytes | None
|
Result of the operation. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.RedisAdapter.get ¶
Get the value of a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value of the key or None if not exists. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.RedisAdapter.mget ¶
Get the values of multiple keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
bytes | str | Iterable[bytes | str]
|
Single key or iterable of keys. |
required |
*args
|
bytes | str
|
Additional keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str | None]
|
List of values. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.RedisAdapter.mset ¶
Set multiple keys to their respective values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mapping
|
Mapping[bytes | str, bytes | str | float]
|
Dictionary of key-value pairs. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool
|
Always returns 'OK'. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.RedisAdapter.keys ¶
Find all keys matching the given pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
bytes | str
|
Pattern to match keys against. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str]
|
List of matching keys. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.RedisAdapter.getset ¶
Set the value of a key and return its old value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key name. |
required |
value
|
bytes | str | float
|
The new value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The previous value or None. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.RedisAdapter.getdel ¶
Get the value of a key and delete it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value of the key or None. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.RedisAdapter.exists ¶
Check if one or more keys exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of keys that exist. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.RedisAdapter.delete ¶
Delete one or more keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of keys deleted. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.RedisAdapter.append ¶
Append a value to a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key name. |
required |
value
|
bytes | str | float
|
The value to append. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Length of the string after append. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.RedisAdapter.ttl ¶
Get the time to live in seconds for a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Time to live in seconds. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.RedisAdapter.type ¶
Determine the type stored at key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str
|
Type of the key's value. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.RedisAdapter.scan ¶
scan(
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> tuple[int, list[bytes | str]]
Scan keys in the database incrementally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cursor
|
int
|
Cursor position. Defaults to 0. |
0
|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of keys to return. Defaults to None. |
None
|
_type
|
str | None
|
Filter by type. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
tuple[int, list[bytes | str]]
|
Tuple of cursor and list of keys. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.RedisAdapter.scan_iter ¶
scan_iter(
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> Iterator[bytes | str]
Iterate over keys in the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of keys to return. Defaults to None. |
None
|
_type
|
str | None
|
Filter by type. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator[bytes | str]
|
Iterator over matching keys. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.RedisAdapter.cluster_info ¶
archipy.adapters.redis.adapters.RedisAdapter.cluster_nodes ¶
cluster_nodes() -> (
dict[
str,
dict[
str,
str
| bool
| list[list[str]]
| list[dict[str, str]],
],
]
| None
)
Get cluster nodes information.
Source code in archipy/adapters/redis/adapter_mixins/cluster.py
archipy.adapters.redis.adapters.RedisAdapter.cluster_slots ¶
archipy.adapters.redis.adapters.RedisAdapter.cluster_key_slot ¶
archipy.adapters.redis.adapters.RedisAdapter.cluster_count_keys_in_slot ¶
Count keys in a specific slot.
archipy.adapters.redis.adapters.RedisAdapter.cluster_get_keys_in_slot ¶
Get keys in a specific slot.
Source code in archipy/adapters/redis/adapter_mixins/cluster.py
archipy.adapters.redis.adapters.RedisAdapter.ping ¶
Ping the Redis server.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool
|
'PONG' if successful. |
archipy.adapters.redis.adapters.RedisAdapter.flushdb ¶
Delete all keys in the current database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asynchronous
|
bool
|
Whether Redis should flush asynchronously. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.adapters.RedisAdapter.get_pipeline ¶
Get a pipeline object for executing multiple commands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transaction
|
Any
|
Whether to use transactions. Defaults to True. |
True
|
shard_hint
|
Any
|
Hint for sharding. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Pipeline |
Pipeline
|
Pipeline object. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.adapters.RedisAdapter.config_set ¶
Set a Redis server configuration parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The configuration parameter name. |
required |
value
|
str
|
The value to set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.adapters.RedisAdapter.config_get ¶
Get Redis server configuration parameters matching a pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
str
|
Pattern to match configuration parameter names. Defaults to "*". |
'*'
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
dict[str, str]
|
Dictionary of configuration parameter names to values. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.adapters.RedisAdapter.search_index ¶
archipy.adapters.redis.adapters.RedisAdapter.list_search_indexes ¶
archipy.adapters.redis.adapters.AsyncRedisAdapter ¶
Bases: AsyncRedisConnectionMixin, AsyncRedisClusterMixin, AsyncRedisKeysMixin, AsyncRedisListsMixin, AsyncRedisSetsMixin, AsyncRedisSortedSetsMixin, AsyncRedisArraysMixin, AsyncRedisHashesMixin, AsyncRedisPubSubMixin, AsyncRedisPort
Async adapter for Redis operations providing a standardized interface.
Implements AsyncRedisPort over async redis-py clients. Maintains separate read/write clients for replica-friendly deployments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
redis_config
|
RedisConfig | None
|
Redis settings. Uses global config when None. |
None
|
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.client
instance-attribute
¶
archipy.adapters.redis.adapters.AsyncRedisAdapter.read_only_client
instance-attribute
¶
archipy.adapters.redis.adapters.AsyncRedisAdapter.publish
async
¶
Publish message to channel asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
bytes | str
|
Channel name. |
required |
message
|
bytes | str
|
Message to publish. |
required |
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of subscribers received message. |
Source code in archipy/adapters/redis/adapter_mixins/pubsub.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.pubsub_channels
async
¶
List active channels matching pattern asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
bytes | str
|
Pattern to match. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str]
|
List of channel names. |
Source code in archipy/adapters/redis/adapter_mixins/pubsub.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.pubsub
async
¶
Get PubSub object for channel subscription asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
AsyncPubSub |
PubSub
|
PubSub object. |
Source code in archipy/adapters/redis/adapter_mixins/pubsub.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hdel
async
¶
Delete fields from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
*keys
|
str | bytes
|
Fields to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of fields deleted. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hexists
async
¶
Check if field exists in hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str
|
Field to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if exists, False otherwise. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hget
async
¶
Get field value from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str
|
Field to get. |
required |
Returns:
| Type | Description |
|---|---|
bytes | str | None
|
str | None: Value or None. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hgetall
async
¶
Get all fields and values from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Type | Description |
|---|---|
dict[bytes | str, bytes | str]
|
dict[str, Any]: Dictionary of field-value pairs. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hkeys
async
¶
Get all fields from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
List of field names. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hlen
async
¶
Get number of fields in hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of fields. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hset
async
¶
hset(
name: str,
key: str | bytes | None = None,
value: str | bytes | None = None,
mapping: dict | None = None,
items: list | None = None,
) -> int
Set fields in hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str | bytes | None
|
Single field name. Defaults to None. |
None
|
value
|
str | bytes | None
|
Single field value. Defaults to None. |
None
|
mapping
|
dict | None
|
Field-value pairs dict. Defaults to None. |
None
|
items
|
list | None
|
Field-value pairs list. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of fields set. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hmget
async
¶
Get multiple field values from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
keys
|
list
|
List of field names. |
required |
*args
|
str | bytes
|
Additional field names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str | None]
|
List of field values. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hvals
async
¶
Get all values from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
List of values. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.arset
async
¶
Set one or more contiguous values in an array asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
index
|
int
|
The starting index to set values at. |
required |
*values
|
bytes | str | float
|
Values to store at consecutive indices. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of previously empty slots that were set. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.arget
async
¶
Get the value at an index in an array asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
index
|
int
|
The index to read. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value at the index, or None if unset. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.arlen
async
¶
Get the number of populated elements in an array asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of populated elements. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.ardel
async
¶
Delete one or more indices from an array asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
*indices
|
int
|
Indices to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of elements deleted. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.arring
async
¶
Insert values into an array as a fixed-size ring buffer asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
size
|
int
|
The fixed size of the ring buffer. |
required |
*values
|
bytes | str | float
|
Values to insert. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The last index where a value was inserted. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zadd
async
¶
zadd(
name: bytes | str,
mapping: Mapping[bytes | str, bytes | str | float],
nx: bool = False,
xx: bool = False,
ch: bool = False,
incr: bool = False,
gt: bool = False,
lt: bool = False,
) -> int | float | None
Add members to sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
mapping
|
Mapping[bytes | str, bytes | str | float]
|
Member-score pairs. |
required |
nx
|
bool
|
Only add new elements. Defaults to False. |
False
|
xx
|
bool
|
Only update existing. Defaults to False. |
False
|
ch
|
bool
|
Return changed count. Defaults to False. |
False
|
incr
|
bool
|
Increment scores. Defaults to False. |
False
|
gt
|
bool
|
Only if greater. Defaults to False. |
False
|
lt
|
bool
|
Only if less. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int | float | None
|
Number of elements added or modified. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zcard
async
¶
Get number of members in sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of members. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zcount
async
¶
Count members in score range asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
min_
|
float | str
|
Minimum score. |
required |
max_
|
float | str
|
Maximum score. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of members in range. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zpopmax
async
¶
zpopmax(
name: bytes | str, count: int | None = None
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Pop highest scored members asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
count
|
int | None
|
Number to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of popped member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zpopmin
async
¶
zpopmin(
name: bytes | str, count: int | None = None
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Pop lowest scored members asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
count
|
int | None
|
Number to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of popped member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zrange
async
¶
zrange(
name: bytes | str,
start: int,
end: int,
desc: bool = False,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
byscore: bool = False,
bylex: bool = False,
offset: int | None = None,
num: int | None = None,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Get range from sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
start
|
int
|
Start index or score. |
required |
end
|
int
|
End index or score. |
required |
desc
|
bool
|
Descending order. Defaults to False. |
False
|
withscores
|
bool
|
Include scores. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Score cast function. Defaults to float. |
float
|
byscore
|
bool
|
Range by score. Defaults to False. |
False
|
bylex
|
bool
|
Range by lex. Defaults to False. |
False
|
offset
|
int | None
|
Offset for byscore/bylex. Defaults to None. |
None
|
num
|
int | None
|
Count for byscore/bylex. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zrevrange
async
¶
zrevrange(
name: bytes | str,
start: int,
end: int,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Get reverse range from sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
start
|
int
|
Start index. |
required |
end
|
int
|
End index. |
required |
withscores
|
bool
|
Include scores. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Score cast function. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zrangebyscore
async
¶
zrangebyscore(
name: bytes | str,
min_: float | str,
max_: float | str,
start: int | None = None,
num: int | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Get members by score range asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
min_
|
float | str
|
Minimum score. |
required |
max_
|
float | str
|
Maximum score. |
required |
start
|
int | None
|
Offset. Defaults to None. |
None
|
num
|
int | None
|
Count. Defaults to None. |
None
|
withscores
|
bool
|
Include scores. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Score cast function. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zrank
async
¶
Get rank of member in sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
value
|
bytes | str | float
|
Member to find rank for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int | list[Any] | None
|
Rank or None if not found. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zrem
async
¶
Remove members from sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of members removed. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zscore
async
¶
Get score of member in sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
value
|
bytes | str | float
|
Member to get score for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
float | None
|
Score or None if not found. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zunion
async
¶
zunion(
keys: Mapping[bytes | str, float]
| Iterable[bytes | str],
aggregate: str | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Compute the union of multiple sorted sets asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Mapping[bytes | str, float] | Iterable[bytes | str]
|
Sorted set keys, optionally mapped to per-set weights. |
required |
aggregate
|
str | None
|
"SUM", "MIN", "MAX", or "COUNT". Defaults to "SUM". |
None
|
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zinter
async
¶
zinter(
keys: Mapping[bytes | str, float]
| Iterable[bytes | str],
aggregate: str | None = None,
withscores: bool = False,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Compute the intersection of multiple sorted sets asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Mapping[bytes | str, float] | Iterable[bytes | str]
|
Sorted set keys, optionally mapped to per-set weights. |
required |
aggregate
|
str | None
|
"SUM", "MIN", "MAX", or "COUNT". Defaults to "SUM". |
None
|
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zincrby
async
¶
Increment member score in sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
amount
|
float
|
Amount to increment by. |
required |
value
|
bytes | str | float
|
Member to increment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
float | None
|
New score of the member. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.sscan
async
¶
sscan(
name: bytes | str,
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
) -> tuple[int, list[bytes | str]]
Scan set members incrementally asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The set key name. |
required |
cursor
|
int
|
Cursor position. Defaults to 0. |
0
|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of elements. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
tuple[int, list[bytes | str]]
|
Tuple of cursor and list of members. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.sscan_iter
async
¶
sscan_iter(
name: bytes | str,
match: bytes | str | None = None,
count: int | None = None,
) -> AsyncIterator[bytes | str]
Iterate over set members asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The set key name. |
required |
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of elements. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
AsyncIterator[bytes | str]
|
Iterator[Any]: Iterator over set members. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.sadd
async
¶
Add members to a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
*values
|
bytes | str | float
|
Members to add. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of elements added. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.scard
async
¶
Get number of members in a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of members. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.sismember
async
¶
Check if value is in set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
value
|
str
|
Value to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if value is member, False otherwise. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.smembers
async
¶
Get all members of a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
_set[bytes | str]
|
Set of all members. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.spop
async
¶
Remove and return random set members asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
count
|
int | None
|
Number of members to pop. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
bytes | float | int | str | list | None
|
bytes | float | int | str | list | None: Popped member(s) or None. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.srem
async
¶
Remove members from a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of members removed. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.sunion
async
¶
Get union of multiple sets asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
bytes | str
|
First set key. |
required |
*args
|
bytes | str
|
Additional set keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
_set[bytes | str]
|
Set containing union of all sets. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.llen
async
¶
Get the length of a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Length of the list. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.lpop
async
¶
Remove and return elements from list left asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int | None
|
Number of elements to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
bytes | str | list[bytes | str] | None
|
Popped element(s) or None if list is empty. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.lpush
async
¶
Push elements to list left asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Length of the list after push. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.lrange
async
¶
Get a range of elements from a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
start
|
int
|
Start index. |
required |
end
|
int
|
End index. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
List of elements in range. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.lrem
async
¶
Remove elements from a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int
|
Number of occurrences to remove. |
required |
value
|
str
|
Value to remove. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of elements removed. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.lset
async
¶
Set list element by index asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
index
|
int
|
Index of the element. |
required |
value
|
str
|
New value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.rpop
async
¶
Remove and return elements from list right asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int | None
|
Number of elements to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
bytes | str | list[bytes | str] | None
|
Popped element(s) or None if list is empty. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.rpush
async
¶
Push elements to list right asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Length of the list after push. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.pttl
async
¶
Get the time to live in milliseconds for a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Time to live in milliseconds. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.incrby
async
¶
Increment the integer value of a key by the given amount asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
amount
|
int
|
Amount to increment by. Defaults to 1. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The new value after increment. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.increx
async
¶
increx(
name: bytes | str,
byfloat: float | None = None,
byint: int | None = None,
lbound: float | None = None,
ubound: float | None = None,
saturate: bool = False,
ex: int | timedelta | None = None,
px: int | timedelta | None = None,
exat: int | datetime | None = None,
pxat: int | datetime | None = None,
persist: bool = False,
enx: bool = False,
) -> list[Any]
Increment a windowed counter with bounds and expiration control asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to increment. |
required |
byfloat
|
float
|
Increment amount as a float. |
None
|
byint
|
int
|
Increment amount as an int. |
None
|
lbound
|
float | int
|
Lower bound for the resulting value. |
None
|
ubound
|
float | int
|
Upper bound for the resulting value. |
None
|
saturate
|
bool
|
Clamp out-of-bounds results instead of rejecting. Defaults to False. |
False
|
ex
|
int | timedelta | None
|
Expire time in seconds. |
None
|
px
|
int | timedelta | None
|
Expire time in milliseconds. |
None
|
exat
|
int | datetime | None
|
Absolute expiration time in seconds. |
None
|
pxat
|
int | datetime | None
|
Absolute expiration time in milliseconds. |
None
|
persist
|
bool
|
Remove any existing expiration. Defaults to False. |
False
|
enx
|
bool
|
Set expiration only if none already exists. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[Any]
|
A two-element list of [new_value, actual_increment_applied]. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.set
async
¶
set(
name: bytes | str,
value: bytes | str | float,
ex: int | timedelta | None = None,
px: int | timedelta | None = None,
nx: bool = False,
xx: bool = False,
keepttl: bool = False,
get: bool = False,
exat: int | datetime | None = None,
pxat: int | datetime | None = None,
) -> bool | str | bytes | None
Set the value of a key with optional expiration asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
value
|
int | bytes | str | float
|
The value to set. |
required |
ex
|
int | timedelta | None
|
Expire time in seconds. |
None
|
px
|
int | timedelta | None
|
Expire time in milliseconds. |
None
|
nx
|
bool
|
Only set if key doesn't exist. |
False
|
xx
|
bool
|
Only set if key exists. |
False
|
keepttl
|
bool
|
Retain the TTL from the previous value. |
False
|
get
|
bool
|
Return the old value. |
False
|
exat
|
int | datetime | None
|
Absolute expiration time in seconds. |
None
|
pxat
|
int | datetime | None
|
Absolute expiration time in milliseconds. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool | str | bytes | None
|
Result of the operation. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.get
async
¶
Get the value of a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value of the key or None if not exists. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.mget
async
¶
Get the values of multiple keys asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
bytes | str | Iterable[bytes | str]
|
Single key or iterable of keys. |
required |
*args
|
bytes | str
|
Additional keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str | None]
|
List of values. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.mset
async
¶
Set multiple keys to their values asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mapping
|
Mapping[bytes | str, bytes | str | float]
|
Dictionary of key-value pairs. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool
|
Always returns 'OK'. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.keys
async
¶
Find all keys matching the pattern asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
bytes | str
|
Pattern to match keys against. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str]
|
List of matching keys. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.getset
async
¶
Set a key's value and return its old value asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key name. |
required |
value
|
bytes | str | float
|
The new value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The previous value or None. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.getdel
async
¶
Get a key's value and delete it asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value of the key or None. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.exists
async
¶
Check if keys exist asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of keys that exist. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.delete
async
¶
Delete keys asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of keys deleted. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.append
async
¶
Append a value to a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key name. |
required |
value
|
bytes | str | float
|
The value to append. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Length of the string after append. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.ttl
async
¶
Get the time to live in seconds for a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Time to live in seconds. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.type
async
¶
Determine the type stored at key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str
|
Type of the key's value. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.scan
async
¶
scan(
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> tuple[int, list[bytes | str]]
Scan keys in database incrementally asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cursor
|
int
|
Cursor position. Defaults to 0. |
0
|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of keys. Defaults to None. |
None
|
_type
|
str | None
|
Filter by type. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
tuple[int, list[bytes | str]]
|
Tuple of cursor and list of keys. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.scan_iter
async
¶
scan_iter(
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> AsyncIterator[bytes | str]
Iterate over keys in database asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of keys. Defaults to None. |
None
|
_type
|
str | None
|
Filter by type. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
AsyncIterator[bytes | str]
|
Iterator[Any]: Iterator over matching keys. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.cluster_info
async
¶
Get cluster information asynchronously.
archipy.adapters.redis.adapters.AsyncRedisAdapter.cluster_nodes
async
¶
cluster_nodes() -> (
dict[
str,
dict[
str,
str
| bool
| list[list[str]]
| list[dict[str, str]],
],
]
| None
)
Get cluster nodes information asynchronously.
Source code in archipy/adapters/redis/adapter_mixins/cluster.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.cluster_slots
async
¶
Get cluster slots mapping asynchronously.
archipy.adapters.redis.adapters.AsyncRedisAdapter.cluster_key_slot
async
¶
Get the hash slot for a key asynchronously.
archipy.adapters.redis.adapters.AsyncRedisAdapter.cluster_count_keys_in_slot
async
¶
Count keys in a specific slot asynchronously.
Source code in archipy/adapters/redis/adapter_mixins/cluster.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.cluster_get_keys_in_slot
async
¶
Get keys in a specific slot asynchronously.
Source code in archipy/adapters/redis/adapter_mixins/cluster.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.ping
async
¶
Ping the Redis server asynchronously.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool
|
'PONG' if successful. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.flushdb
async
¶
Delete all keys in the current database asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asynchronous
|
bool
|
Whether Redis should flush asynchronously. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.get_pipeline
async
¶
get_pipeline(
transaction: Any = True, shard_hint: Any = None
) -> AsyncPipeline | AsyncClusterPipeline
Get pipeline for multiple commands asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transaction
|
Any
|
Use transactions. Defaults to True. |
True
|
shard_hint
|
Any
|
Sharding hint. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Pipeline | ClusterPipeline
|
AsyncPipeline | AsyncClusterPipeline: Pipeline object. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.config_set
async
¶
Set a Redis server configuration parameter asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The configuration parameter name. |
required |
value
|
str
|
The value to set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.config_get
async
¶
Get Redis server configuration parameters matching a pattern asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
str
|
Pattern to match configuration parameter names. Defaults to "*". |
'*'
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
dict[str, str]
|
Dictionary of configuration parameter names to values. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.search_index ¶
Return an index-bound async RediSearch handle.
archipy.adapters.redis.adapters.AsyncRedisAdapter.list_search_indexes
async
¶
List RediSearch indexes available on the server asynchronously.
options: show_root_toc_entry: false heading_level: 3
Search Ports¶
Abstract port interfaces for index-bound RediSearch operations (sync and async).
Port interfaces for Redis Search operations.
archipy.adapters.redis.search_ports.RedisSearchHandlePort ¶
Index-bound RediSearch operations contract.
Source code in archipy/adapters/redis/search_ports.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
archipy.adapters.redis.search_ports.RedisSearchHandlePort.create_index
abstractmethod
¶
create_index(
schema: IndexSchemaDTO,
prefix: str,
index_type: RedisIndexType | None = None,
**kwargs: Any,
) -> bool
Create a RediSearch index.
archipy.adapters.redis.search_ports.RedisSearchHandlePort.drop_index
abstractmethod
¶
archipy.adapters.redis.search_ports.RedisSearchHandlePort.info
abstractmethod
¶
archipy.adapters.redis.search_ports.RedisSearchHandlePort.alter_schema_add
abstractmethod
¶
alter_schema_add(
fields: IndexFieldConfig | list[IndexFieldConfig],
*,
index_type: RedisIndexType | None = None,
) -> bool
Add fields to an existing index schema.
Source code in archipy/adapters/redis/search_ports.py
archipy.adapters.redis.search_ports.RedisSearchHandlePort.upsert_hash
abstractmethod
¶
upsert_hash(
doc_id: str,
fields: dict[str, str | int | float],
vector_field: str | None = None,
vector: list[float] | None = None,
*,
replace: bool = True,
) -> bool
Upsert a HASH document and index it.
Source code in archipy/adapters/redis/search_ports.py
archipy.adapters.redis.search_ports.RedisSearchHandlePort.upsert_hash_dto
abstractmethod
¶
archipy.adapters.redis.search_ports.RedisSearchHandlePort.upsert_json
abstractmethod
¶
archipy.adapters.redis.search_ports.RedisSearchHandlePort.upsert_json_dto
abstractmethod
¶
archipy.adapters.redis.search_ports.RedisSearchHandlePort.get_document
abstractmethod
¶
archipy.adapters.redis.search_ports.RedisSearchHandlePort.delete_document
abstractmethod
¶
archipy.adapters.redis.search_ports.RedisSearchHandlePort.search
abstractmethod
¶
archipy.adapters.redis.search_ports.RedisSearchHandlePort.aggregate
abstractmethod
¶
archipy.adapters.redis.search_ports.RedisSearchHandlePort.add_alias
abstractmethod
¶
archipy.adapters.redis.search_ports.RedisSearchHandlePort.update_alias
abstractmethod
¶
archipy.adapters.redis.search_ports.RedisSearchHandlePort.delete_alias
abstractmethod
¶
archipy.adapters.redis.search_ports.AsyncRedisSearchHandlePort ¶
Asynchronous index-bound RediSearch operations contract.
Source code in archipy/adapters/redis/search_ports.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
archipy.adapters.redis.search_ports.AsyncRedisSearchHandlePort.create_index
abstractmethod
async
¶
create_index(
schema: IndexSchemaDTO,
prefix: str,
index_type: RedisIndexType | None = None,
**kwargs: Any,
) -> bool
Create a RediSearch index asynchronously.
Source code in archipy/adapters/redis/search_ports.py
archipy.adapters.redis.search_ports.AsyncRedisSearchHandlePort.drop_index
abstractmethod
async
¶
archipy.adapters.redis.search_ports.AsyncRedisSearchHandlePort.info
abstractmethod
async
¶
archipy.adapters.redis.search_ports.AsyncRedisSearchHandlePort.alter_schema_add
abstractmethod
async
¶
alter_schema_add(
fields: IndexFieldConfig | list[IndexFieldConfig],
*,
index_type: RedisIndexType | None = None,
) -> bool
Add fields to an existing index schema asynchronously.
Source code in archipy/adapters/redis/search_ports.py
archipy.adapters.redis.search_ports.AsyncRedisSearchHandlePort.upsert_hash
abstractmethod
async
¶
upsert_hash(
doc_id: str,
fields: dict[str, str | int | float],
vector_field: str | None = None,
vector: list[float] | None = None,
*,
replace: bool = True,
) -> bool
Upsert a HASH document and index it asynchronously.
Source code in archipy/adapters/redis/search_ports.py
archipy.adapters.redis.search_ports.AsyncRedisSearchHandlePort.upsert_hash_dto
abstractmethod
async
¶
Upsert a HASH document from a DTO asynchronously.
archipy.adapters.redis.search_ports.AsyncRedisSearchHandlePort.upsert_json
abstractmethod
async
¶
upsert_json(
doc_id: str,
payload: dict[str, str | int | float | list[float]],
json_path: str = "$",
) -> bool
Upsert a JSON document asynchronously.
Source code in archipy/adapters/redis/search_ports.py
archipy.adapters.redis.search_ports.AsyncRedisSearchHandlePort.upsert_json_dto
abstractmethod
async
¶
archipy.adapters.redis.search_ports.AsyncRedisSearchHandlePort.get_document
abstractmethod
async
¶
archipy.adapters.redis.search_ports.AsyncRedisSearchHandlePort.delete_document
abstractmethod
async
¶
Remove a document from the index asynchronously.
archipy.adapters.redis.search_ports.AsyncRedisSearchHandlePort.search
abstractmethod
async
¶
Execute a RediSearch query asynchronously (text, KNN, or hybrid).
archipy.adapters.redis.search_ports.AsyncRedisSearchHandlePort.aggregate
abstractmethod
async
¶
Execute a RediSearch aggregation asynchronously.
archipy.adapters.redis.search_ports.AsyncRedisSearchHandlePort.add_alias
abstractmethod
async
¶
archipy.adapters.redis.search_ports.AsyncRedisSearchHandlePort.update_alias
abstractmethod
async
¶
archipy.adapters.redis.search_ports.AsyncRedisSearchHandlePort.delete_alias
abstractmethod
async
¶
options: show_root_toc_entry: false heading_level: 3
Search Adapters¶
Concrete RediSearch handle implementations, plus pack_vector() and unpack_vector() helpers for float32 vector
encoding. Supports FLAT, HNSW, and SVS-VAMANA vector indexes, KNN and VECTOR_RANGE queries, and runtime
tuning parameters including cluster shard_k_ratio.
Redis Search adapter implementations.
archipy.adapters.redis.search.RedisSearchHandle ¶
Bases: RedisSearchHandlePort
Synchronous index-bound RediSearch handle.
Source code in archipy/adapters/redis/search.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 | |
archipy.adapters.redis.search.RedisSearchHandle.create_index ¶
create_index(
schema: IndexSchemaDTO,
prefix: str,
index_type: RedisIndexType | None = None,
**kwargs: Any,
) -> bool
Create a RediSearch index.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.RedisSearchHandle.drop_index ¶
archipy.adapters.redis.search.RedisSearchHandle.info ¶
archipy.adapters.redis.search.RedisSearchHandle.alter_schema_add ¶
alter_schema_add(
fields: IndexFieldConfig | list[IndexFieldConfig],
*,
index_type: RedisIndexType | None = None,
) -> bool
Add fields to an existing index schema.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.RedisSearchHandle.upsert_hash ¶
upsert_hash(
doc_id: str,
fields: dict[str, str | int | float],
vector_field: str | None = None,
vector: list[float] | None = None,
*,
replace: bool = True,
) -> bool
Upsert a HASH document and index it.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.RedisSearchHandle.upsert_hash_dto ¶
Upsert a HASH document from a DTO.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.RedisSearchHandle.upsert_json ¶
upsert_json(
doc_id: str,
payload: dict[str, str | int | float | list[float]],
json_path: str = "$",
) -> bool
Upsert a JSON document.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.RedisSearchHandle.upsert_json_dto ¶
archipy.adapters.redis.search.RedisSearchHandle.get_document ¶
Load a document by ID.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.RedisSearchHandle.delete_document ¶
Remove a document from the index.
archipy.adapters.redis.search.RedisSearchHandle.search ¶
Execute a RediSearch query.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.RedisSearchHandle.aggregate ¶
Execute a RediSearch aggregation.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.RedisSearchHandle.add_alias ¶
archipy.adapters.redis.search.RedisSearchHandle.update_alias ¶
archipy.adapters.redis.search.AsyncRedisSearchHandle ¶
Bases: AsyncRedisSearchHandlePort
Asynchronous index-bound RediSearch handle.
Source code in archipy/adapters/redis/search.py
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 | |
archipy.adapters.redis.search.AsyncRedisSearchHandle.create_index
async
¶
create_index(
schema: IndexSchemaDTO,
prefix: str,
index_type: RedisIndexType | None = None,
**kwargs: Any,
) -> bool
Create a RediSearch index asynchronously.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.AsyncRedisSearchHandle.drop_index
async
¶
Drop the RediSearch index asynchronously.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.AsyncRedisSearchHandle.info
async
¶
archipy.adapters.redis.search.AsyncRedisSearchHandle.alter_schema_add
async
¶
alter_schema_add(
fields: IndexFieldConfig | list[IndexFieldConfig],
*,
index_type: RedisIndexType | None = None,
) -> bool
Add fields to an existing index schema asynchronously.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.AsyncRedisSearchHandle.upsert_hash
async
¶
upsert_hash(
doc_id: str,
fields: dict[str, str | int | float],
vector_field: str | None = None,
vector: list[float] | None = None,
*,
replace: bool = True,
) -> bool
Upsert a HASH document and index it asynchronously.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.AsyncRedisSearchHandle.upsert_hash_dto
async
¶
Upsert a HASH document from a DTO asynchronously.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.AsyncRedisSearchHandle.upsert_json
async
¶
upsert_json(
doc_id: str,
payload: dict[str, str | int | float | list[float]],
json_path: str = "$",
) -> bool
Upsert a JSON document asynchronously.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.AsyncRedisSearchHandle.upsert_json_dto
async
¶
Upsert a JSON document from a DTO asynchronously.
archipy.adapters.redis.search.AsyncRedisSearchHandle.get_document
async
¶
Load a document by ID asynchronously.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.AsyncRedisSearchHandle.delete_document
async
¶
Remove a document from the index asynchronously.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.AsyncRedisSearchHandle.search
async
¶
Execute a RediSearch query asynchronously.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.AsyncRedisSearchHandle.aggregate
async
¶
Execute a RediSearch aggregation asynchronously.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.AsyncRedisSearchHandle.add_alias
async
¶
archipy.adapters.redis.search.AsyncRedisSearchHandle.update_alias
async
¶
Update an alias to point to this index asynchronously.
archipy.adapters.redis.search.AsyncRedisSearchHandle.delete_alias
async
¶
archipy.adapters.redis.search.list_redis_search_indexes ¶
List RediSearch index names from a standalone or cluster client.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.list_redis_search_indexes_async
async
¶
List RediSearch index names from an async standalone or cluster client.
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.pack_vector ¶
Pack a float vector into float32 little-endian bytes for RediSearch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector
|
list[float]
|
Embedding values. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Binary blob suitable for Redis VECTOR fields and KNN params. |
Source code in archipy/adapters/redis/search.py
archipy.adapters.redis.search.unpack_vector ¶
Unpack float32 little-endian bytes into a vector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
blob
|
bytes
|
Binary vector data from Redis. |
required |
dim
|
int
|
Expected vector dimensionality. |
required |
Returns:
| Type | Description |
|---|---|
list[float]
|
Decoded embedding values. |
Source code in archipy/adapters/redis/search.py
options: show_root_toc_entry: false heading_level: 3
Mocks¶
In-memory mock implementation of the Redis port for use in unit tests and BDD scenarios.
Mock Redis adapters for testing.
archipy.adapters.redis.mocks.FakeRedisClusterWrapper ¶
Bases: FakeRedis
Wrapper around FakeRedis that adds cluster-specific methods.
Source code in archipy/adapters/redis/mocks.py
archipy.adapters.redis.mocks.FakeRedisClusterWrapper.cluster_info ¶
archipy.adapters.redis.mocks.FakeRedisClusterWrapper.cluster_nodes ¶
archipy.adapters.redis.mocks.FakeRedisClusterWrapper.cluster_slots ¶
archipy.adapters.redis.mocks.FakeRedisClusterWrapper.cluster_keyslot ¶
archipy.adapters.redis.mocks.FakeRedisClusterWrapper.cluster_countkeysinslot ¶
archipy.adapters.redis.mocks.FakeRedisClusterWrapper.cluster_get_keys_in_slot ¶
archipy.adapters.redis.mocks.FakeAsyncRedisClusterWrapper ¶
Bases: FakeAsyncRedis
Wrapper around FakeAsyncRedis that adds cluster-specific methods.
Source code in archipy/adapters/redis/mocks.py
archipy.adapters.redis.mocks.FakeAsyncRedisClusterWrapper.cluster_info
async
¶
archipy.adapters.redis.mocks.FakeAsyncRedisClusterWrapper.cluster_nodes
async
¶
archipy.adapters.redis.mocks.FakeAsyncRedisClusterWrapper.cluster_slots
async
¶
archipy.adapters.redis.mocks.FakeAsyncRedisClusterWrapper.cluster_keyslot
async
¶
archipy.adapters.redis.mocks.FakeAsyncRedisClusterWrapper.cluster_countkeysinslot
async
¶
archipy.adapters.redis.mocks.FakeAsyncRedisClusterWrapper.cluster_get_keys_in_slot
async
¶
archipy.adapters.redis.mocks.RedisMock ¶
Bases: RedisAdapter
A Redis adapter implementation using fakeredis for testing.
Source code in archipy/adapters/redis/mocks.py
archipy.adapters.redis.mocks.RedisMock.config
instance-attribute
¶
archipy.adapters.redis.mocks.RedisMock.read_only_client
instance-attribute
¶
archipy.adapters.redis.mocks.RedisMock.publish ¶
Publish a message to a channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
bytes | str
|
Channel name. |
required |
message
|
bytes | str
|
Message to publish. |
required |
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of subscribers that received the message. |
Source code in archipy/adapters/redis/adapter_mixins/pubsub.py
archipy.adapters.redis.mocks.RedisMock.pubsub_channels ¶
List active channels matching a pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
bytes | str
|
Pattern to match channels. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str]
|
List of channel names. |
Source code in archipy/adapters/redis/adapter_mixins/pubsub.py
archipy.adapters.redis.mocks.RedisMock.pubsub ¶
Get a PubSub object for subscribing to channels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
PubSub |
PubSub
|
PubSub object. |
Source code in archipy/adapters/redis/adapter_mixins/pubsub.py
archipy.adapters.redis.mocks.RedisMock.hdel ¶
Delete fields from a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
*keys
|
str | bytes
|
Fields to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of fields deleted. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.RedisMock.hexists ¶
Check if a field exists in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str
|
Field to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if field exists, False otherwise. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.RedisMock.hget ¶
Get the value of a field in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str
|
Field to get. |
required |
Returns:
| Type | Description |
|---|---|
bytes | str | None
|
str | None: Value of the field or None. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.RedisMock.hgetall ¶
Get all fields and values in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Type | Description |
|---|---|
dict[bytes | str, bytes | str]
|
dict[str, Any]: Dictionary of field-value pairs. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.RedisMock.hkeys ¶
Get all fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
List of field names. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.RedisMock.hlen ¶
Get the number of fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of fields. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.RedisMock.hset ¶
hset(
name: str,
key: str | bytes | None = None,
value: str | bytes | None = None,
mapping: dict | None = None,
items: list | None = None,
) -> int
Set fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str | bytes | None
|
Single field name. Defaults to None. |
None
|
value
|
str | bytes | None
|
Single field value. Defaults to None. |
None
|
mapping
|
dict | None
|
Dictionary of field-value pairs. Defaults to None. |
None
|
items
|
list | None
|
List of field-value pairs. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of fields set. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.RedisMock.hmget ¶
Get values of multiple fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
keys
|
list
|
List of field names. |
required |
*args
|
str | bytes
|
Additional field names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str | None]
|
List of field values. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.RedisMock.hvals ¶
Get all values in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
List of values. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.RedisMock.arset ¶
Set one or more contiguous values in an array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
index
|
int
|
The starting index to set values at. |
required |
*values
|
bytes | str | float
|
Values to store at consecutive indices. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of previously empty slots that were set. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.mocks.RedisMock.arget ¶
Get the value at an index in an array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
index
|
int
|
The index to read. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value at the index, or None if unset. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.mocks.RedisMock.arlen ¶
Get the number of populated elements in an array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of populated elements. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.mocks.RedisMock.ardel ¶
Delete one or more indices from an array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
*indices
|
int
|
Indices to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of elements deleted. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.mocks.RedisMock.arring ¶
Insert values into an array as a fixed-size ring buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
size
|
int
|
The fixed size of the ring buffer. |
required |
*values
|
bytes | str | float
|
Values to insert. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The last index where a value was inserted. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.mocks.RedisMock.zadd ¶
zadd(
name: bytes | str,
mapping: Mapping[bytes | str, bytes | str | float],
nx: bool = False,
xx: bool = False,
ch: bool = False,
incr: bool = False,
gt: bool = False,
lt: bool = False,
) -> int | float | None
Add members to a sorted set with scores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
mapping
|
Mapping[bytes | str, bytes | str | float]
|
Member-score pairs. |
required |
nx
|
bool
|
Only add new elements. Defaults to False. |
False
|
xx
|
bool
|
Only update existing elements. Defaults to False. |
False
|
ch
|
bool
|
Return number of changed elements. Defaults to False. |
False
|
incr
|
bool
|
Increment existing scores. Defaults to False. |
False
|
gt
|
bool
|
Only update if score is greater. Defaults to False. |
False
|
lt
|
bool
|
Only update if score is less. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int | float | None
|
Number of elements added or modified. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.RedisMock.zcard ¶
Get the number of members in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of members. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.RedisMock.zcount ¶
Count members in a sorted set with scores in range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
min_
|
float | str
|
Minimum score. |
required |
max_
|
float | str
|
Maximum score. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of members in range. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.RedisMock.zpopmax ¶
zpopmax(
name: bytes | str, count: int | None = None
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Remove and return members with highest scores from sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
count
|
int | None
|
Number of members to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of popped member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.RedisMock.zpopmin ¶
zpopmin(
name: bytes | str, count: int | None = None
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Remove and return members with lowest scores from sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
count
|
int | None
|
Number of members to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of popped member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.RedisMock.zrange ¶
zrange(
name: bytes | str,
start: int,
end: int,
desc: bool = False,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
byscore: bool = False,
bylex: bool = False,
offset: int | None = None,
num: int | None = None,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Get a range of members from a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
start
|
int
|
Start index or score. |
required |
end
|
int
|
End index or score. |
required |
desc
|
bool
|
Sort in descending order. Defaults to False. |
False
|
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
byscore
|
bool
|
Range by score. Defaults to False. |
False
|
bylex
|
bool
|
Range by lexicographical order. Defaults to False. |
False
|
offset
|
int | None
|
Offset for byscore/bylex. Defaults to None. |
None
|
num
|
int | None
|
Count for byscore/bylex. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.RedisMock.zrevrange ¶
zrevrange(
name: bytes | str,
start: int,
end: int,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Get a range of members from a sorted set in reverse order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
start
|
int
|
Start index. |
required |
end
|
int
|
End index. |
required |
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.RedisMock.zrangebyscore ¶
zrangebyscore(
name: bytes | str,
min_: float | str,
max_: float | str,
start: int | None = None,
num: int | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Get members from a sorted set by score range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
min_
|
float | str
|
Minimum score. |
required |
max_
|
float | str
|
Maximum score. |
required |
start
|
int | None
|
Offset. Defaults to None. |
None
|
num
|
int | None
|
Count. Defaults to None. |
None
|
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.RedisMock.zrank ¶
Get the rank of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
value
|
bytes | str | float
|
Member to find rank for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int | list[Any] | None
|
Rank of the member or None if not found. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.RedisMock.zrem ¶
Remove members from a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of members removed. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.RedisMock.zscore ¶
Get the score of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
value
|
bytes | str | float
|
Member to get score for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
float | None
|
Score of the member or None if not found. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.RedisMock.zunion ¶
zunion(
keys: Mapping[bytes | str, float]
| Iterable[bytes | str],
aggregate: str | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Compute the union of multiple sorted sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Mapping[bytes | str, float] | Iterable[bytes | str]
|
Sorted set keys, optionally mapped to per-set weights. |
required |
aggregate
|
str | None
|
"SUM", "MIN", "MAX", or "COUNT". Defaults to "SUM". |
None
|
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.RedisMock.zinter ¶
zinter(
keys: Mapping[bytes | str, float]
| Iterable[bytes | str],
aggregate: str | None = None,
withscores: bool = False,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Compute the intersection of multiple sorted sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Mapping[bytes | str, float] | Iterable[bytes | str]
|
Sorted set keys, optionally mapped to per-set weights. |
required |
aggregate
|
str | None
|
"SUM", "MIN", "MAX", or "COUNT". Defaults to "SUM". |
None
|
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.RedisMock.zincrby ¶
Increment the score of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
amount
|
float
|
Amount to increment by. |
required |
value
|
bytes | str | float
|
Member to increment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
float | None
|
New score of the member. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.RedisMock.sscan ¶
sscan(
name: bytes | str,
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
) -> tuple[int, list[bytes | str]]
Scan members of a set incrementally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The set key name. |
required |
cursor
|
int
|
Cursor position. Defaults to 0. |
0
|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of elements. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
tuple[int, list[bytes | str]]
|
Tuple of cursor and list of members. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.RedisMock.sscan_iter ¶
sscan_iter(
name: bytes | str,
match: bytes | str | None = None,
count: int | None = None,
) -> Iterator[bytes | str]
Iterate over members of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The set key name. |
required |
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of elements. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator[bytes | str]
|
Iterator over set members. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.RedisMock.sadd ¶
Add members to a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
*values
|
bytes | str | float
|
Members to add. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of elements added. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.RedisMock.scard ¶
Get the number of members in a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of members. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.RedisMock.sismember ¶
Check if a value is a member of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
value
|
str
|
Value to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if value is a member, False otherwise. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.RedisMock.smembers ¶
Get all members of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
_set[bytes | str]
|
Set of all members. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.RedisMock.spop ¶
Remove and return random members from a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
count
|
int | None
|
Number of members to pop. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
bytes | float | int | str | list | None
|
bytes | float | int | str | list | None: Popped member(s) or None. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.RedisMock.srem ¶
Remove members from a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of members removed. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.RedisMock.sunion ¶
Get the union of multiple sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
bytes | str
|
First set key. |
required |
*args
|
bytes | str
|
Additional set keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
_set[bytes | str]
|
Set containing union of all sets. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.RedisMock.llen ¶
Get the length of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Length of the list. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.mocks.RedisMock.lpop ¶
Remove and return elements from the left of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int | None
|
Number of elements to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
bytes | str | list[bytes | str] | None
|
Popped element(s) or None if list is empty. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.mocks.RedisMock.lpush ¶
Push elements to the left of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Length of the list after push. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.mocks.RedisMock.lrange ¶
Get a range of elements from a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
start
|
int
|
Start index. |
required |
end
|
int
|
End index. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
List of elements in the specified range. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.mocks.RedisMock.lrem ¶
Remove elements from a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int
|
Number of occurrences to remove. |
required |
value
|
str
|
Value to remove. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of elements removed. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.mocks.RedisMock.lset ¶
Set the value of an element in a list by its index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
index
|
int
|
Index of the element. |
required |
value
|
str
|
New value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.mocks.RedisMock.rpop ¶
Remove and return elements from the right of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int | None
|
Number of elements to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
bytes | str | list[bytes | str] | None
|
Popped element(s) or None if list is empty. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.mocks.RedisMock.rpush ¶
Push elements to the right of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Length of the list after push. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.mocks.RedisMock.pttl ¶
Get the time to live in milliseconds for a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Time to live in milliseconds. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.RedisMock.incrby ¶
Increment the integer value of a key by the given amount.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
amount
|
int
|
Amount to increment by. Defaults to 1. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The new value after increment. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.RedisMock.increx ¶
increx(
name: bytes | str,
byfloat: float | None = None,
byint: int | None = None,
lbound: float | None = None,
ubound: float | None = None,
saturate: bool = False,
ex: int | timedelta | None = None,
px: int | timedelta | None = None,
exat: int | datetime | None = None,
pxat: int | datetime | None = None,
persist: bool = False,
enx: bool = False,
) -> list[Any]
Increment a windowed counter with bounds and expiration control.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to increment. |
required |
byfloat
|
float
|
Increment amount as a float. |
None
|
byint
|
int
|
Increment amount as an int. |
None
|
lbound
|
float | int
|
Lower bound for the resulting value. |
None
|
ubound
|
float | int
|
Upper bound for the resulting value. |
None
|
saturate
|
bool
|
Clamp out-of-bounds results instead of rejecting. Defaults to False. |
False
|
ex
|
int | timedelta | None
|
Expire time in seconds. |
None
|
px
|
int | timedelta | None
|
Expire time in milliseconds. |
None
|
exat
|
int | datetime | None
|
Absolute expiration time in seconds. |
None
|
pxat
|
int | datetime | None
|
Absolute expiration time in milliseconds. |
None
|
persist
|
bool
|
Remove any existing expiration. Defaults to False. |
False
|
enx
|
bool
|
Set expiration only if none already exists. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[Any]
|
A two-element list of [new_value, actual_increment_applied]. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.RedisMock.set ¶
set(
name: bytes | str,
value: bytes | str | float,
ex: int | timedelta | None = None,
px: int | timedelta | None = None,
nx: bool = False,
xx: bool = False,
keepttl: bool = False,
get: bool = False,
exat: int | datetime | None = None,
pxat: int | datetime | None = None,
) -> bool | str | bytes | None
Set the value of a key with optional expiration and conditions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
value
|
int | bytes | str | float
|
The value to set. |
required |
ex
|
int | timedelta | None
|
Expire time in seconds. |
None
|
px
|
int | timedelta | None
|
Expire time in milliseconds. |
None
|
nx
|
bool
|
Only set if key doesn't exist. |
False
|
xx
|
bool
|
Only set if key exists. |
False
|
keepttl
|
bool
|
Retain the TTL from the previous value. |
False
|
get
|
bool
|
Return the old value. |
False
|
exat
|
int | datetime | None
|
Absolute expiration time in seconds. |
None
|
pxat
|
int | datetime | None
|
Absolute expiration time in milliseconds. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool | str | bytes | None
|
Result of the operation. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.RedisMock.get ¶
Get the value of a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value of the key or None if not exists. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.RedisMock.mget ¶
Get the values of multiple keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
bytes | str | Iterable[bytes | str]
|
Single key or iterable of keys. |
required |
*args
|
bytes | str
|
Additional keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str | None]
|
List of values. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.RedisMock.mset ¶
Set multiple keys to their respective values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mapping
|
Mapping[bytes | str, bytes | str | float]
|
Dictionary of key-value pairs. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool
|
Always returns 'OK'. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.RedisMock.keys ¶
Find all keys matching the given pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
bytes | str
|
Pattern to match keys against. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str]
|
List of matching keys. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.RedisMock.getset ¶
Set the value of a key and return its old value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key name. |
required |
value
|
bytes | str | float
|
The new value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The previous value or None. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.RedisMock.getdel ¶
Get the value of a key and delete it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value of the key or None. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.RedisMock.exists ¶
Check if one or more keys exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of keys that exist. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.RedisMock.delete ¶
Delete one or more keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of keys deleted. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.RedisMock.append ¶
Append a value to a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key name. |
required |
value
|
bytes | str | float
|
The value to append. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Length of the string after append. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.RedisMock.ttl ¶
Get the time to live in seconds for a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Time to live in seconds. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.RedisMock.type ¶
Determine the type stored at key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str
|
Type of the key's value. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.RedisMock.scan ¶
scan(
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> tuple[int, list[bytes | str]]
Scan keys in the database incrementally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cursor
|
int
|
Cursor position. Defaults to 0. |
0
|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of keys to return. Defaults to None. |
None
|
_type
|
str | None
|
Filter by type. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
tuple[int, list[bytes | str]]
|
Tuple of cursor and list of keys. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.RedisMock.scan_iter ¶
scan_iter(
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> Iterator[bytes | str]
Iterate over keys in the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of keys to return. Defaults to None. |
None
|
_type
|
str | None
|
Filter by type. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator[bytes | str]
|
Iterator over matching keys. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.RedisMock.cluster_info ¶
archipy.adapters.redis.mocks.RedisMock.cluster_nodes ¶
cluster_nodes() -> (
dict[
str,
dict[
str,
str
| bool
| list[list[str]]
| list[dict[str, str]],
],
]
| None
)
Get cluster nodes information.
Source code in archipy/adapters/redis/adapter_mixins/cluster.py
archipy.adapters.redis.mocks.RedisMock.cluster_slots ¶
archipy.adapters.redis.mocks.RedisMock.cluster_key_slot ¶
archipy.adapters.redis.mocks.RedisMock.cluster_count_keys_in_slot ¶
Count keys in a specific slot.
archipy.adapters.redis.mocks.RedisMock.cluster_get_keys_in_slot ¶
Get keys in a specific slot.
Source code in archipy/adapters/redis/adapter_mixins/cluster.py
archipy.adapters.redis.mocks.RedisMock.ping ¶
Ping the Redis server.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool
|
'PONG' if successful. |
archipy.adapters.redis.mocks.RedisMock.flushdb ¶
Delete all keys in the current database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asynchronous
|
bool
|
Whether Redis should flush asynchronously. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.mocks.RedisMock.get_pipeline ¶
Get a pipeline object for executing multiple commands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transaction
|
Any
|
Whether to use transactions. Defaults to True. |
True
|
shard_hint
|
Any
|
Hint for sharding. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Pipeline |
Pipeline
|
Pipeline object. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.mocks.RedisMock.config_set ¶
Set a Redis server configuration parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The configuration parameter name. |
required |
value
|
str
|
The value to set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.mocks.RedisMock.config_get ¶
Get Redis server configuration parameters matching a pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
str
|
Pattern to match configuration parameter names. Defaults to "*". |
'*'
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
dict[str, str]
|
Dictionary of configuration parameter names to values. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.mocks.RedisMock.search_index ¶
archipy.adapters.redis.mocks.RedisMock.list_search_indexes ¶
archipy.adapters.redis.mocks.AsyncRedisMock ¶
Bases: AsyncRedisAdapter
An async Redis adapter implementation using FakeAsyncRedis for testing.
Source code in archipy/adapters/redis/mocks.py
archipy.adapters.redis.mocks.AsyncRedisMock.config
instance-attribute
¶
archipy.adapters.redis.mocks.AsyncRedisMock.client
instance-attribute
¶
archipy.adapters.redis.mocks.AsyncRedisMock.read_only_client
instance-attribute
¶
archipy.adapters.redis.mocks.AsyncRedisMock.publish
async
¶
Publish message to channel asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
bytes | str
|
Channel name. |
required |
message
|
bytes | str
|
Message to publish. |
required |
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of subscribers received message. |
Source code in archipy/adapters/redis/adapter_mixins/pubsub.py
archipy.adapters.redis.mocks.AsyncRedisMock.pubsub_channels
async
¶
List active channels matching pattern asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
bytes | str
|
Pattern to match. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str]
|
List of channel names. |
Source code in archipy/adapters/redis/adapter_mixins/pubsub.py
archipy.adapters.redis.mocks.AsyncRedisMock.pubsub
async
¶
Get PubSub object for channel subscription asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
AsyncPubSub |
PubSub
|
PubSub object. |
Source code in archipy/adapters/redis/adapter_mixins/pubsub.py
archipy.adapters.redis.mocks.AsyncRedisMock.hdel
async
¶
Delete fields from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
*keys
|
str | bytes
|
Fields to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of fields deleted. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.AsyncRedisMock.hexists
async
¶
Check if field exists in hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str
|
Field to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if exists, False otherwise. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.AsyncRedisMock.hget
async
¶
Get field value from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str
|
Field to get. |
required |
Returns:
| Type | Description |
|---|---|
bytes | str | None
|
str | None: Value or None. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.AsyncRedisMock.hgetall
async
¶
Get all fields and values from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Type | Description |
|---|---|
dict[bytes | str, bytes | str]
|
dict[str, Any]: Dictionary of field-value pairs. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.AsyncRedisMock.hkeys
async
¶
Get all fields from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
List of field names. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.AsyncRedisMock.hlen
async
¶
Get number of fields in hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of fields. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.AsyncRedisMock.hset
async
¶
hset(
name: str,
key: str | bytes | None = None,
value: str | bytes | None = None,
mapping: dict | None = None,
items: list | None = None,
) -> int
Set fields in hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str | bytes | None
|
Single field name. Defaults to None. |
None
|
value
|
str | bytes | None
|
Single field value. Defaults to None. |
None
|
mapping
|
dict | None
|
Field-value pairs dict. Defaults to None. |
None
|
items
|
list | None
|
Field-value pairs list. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of fields set. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.AsyncRedisMock.hmget
async
¶
Get multiple field values from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
keys
|
list
|
List of field names. |
required |
*args
|
str | bytes
|
Additional field names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str | None]
|
List of field values. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.AsyncRedisMock.hvals
async
¶
Get all values from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
List of values. |
Source code in archipy/adapters/redis/adapter_mixins/hashes.py
archipy.adapters.redis.mocks.AsyncRedisMock.arset
async
¶
Set one or more contiguous values in an array asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
index
|
int
|
The starting index to set values at. |
required |
*values
|
bytes | str | float
|
Values to store at consecutive indices. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of previously empty slots that were set. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.mocks.AsyncRedisMock.arget
async
¶
Get the value at an index in an array asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
index
|
int
|
The index to read. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value at the index, or None if unset. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.mocks.AsyncRedisMock.arlen
async
¶
Get the number of populated elements in an array asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of populated elements. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.mocks.AsyncRedisMock.ardel
async
¶
Delete one or more indices from an array asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
*indices
|
int
|
Indices to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The number of elements deleted. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.mocks.AsyncRedisMock.arring
async
¶
Insert values into an array as a fixed-size ring buffer asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the array. |
required |
size
|
int
|
The fixed size of the ring buffer. |
required |
*values
|
bytes | str | float
|
Values to insert. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The last index where a value was inserted. |
Source code in archipy/adapters/redis/adapter_mixins/arrays.py
archipy.adapters.redis.mocks.AsyncRedisMock.zadd
async
¶
zadd(
name: bytes | str,
mapping: Mapping[bytes | str, bytes | str | float],
nx: bool = False,
xx: bool = False,
ch: bool = False,
incr: bool = False,
gt: bool = False,
lt: bool = False,
) -> int | float | None
Add members to sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
mapping
|
Mapping[bytes | str, bytes | str | float]
|
Member-score pairs. |
required |
nx
|
bool
|
Only add new elements. Defaults to False. |
False
|
xx
|
bool
|
Only update existing. Defaults to False. |
False
|
ch
|
bool
|
Return changed count. Defaults to False. |
False
|
incr
|
bool
|
Increment scores. Defaults to False. |
False
|
gt
|
bool
|
Only if greater. Defaults to False. |
False
|
lt
|
bool
|
Only if less. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int | float | None
|
Number of elements added or modified. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.zcard
async
¶
Get number of members in sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of members. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.zcount
async
¶
Count members in score range asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
min_
|
float | str
|
Minimum score. |
required |
max_
|
float | str
|
Maximum score. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of members in range. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.zpopmax
async
¶
zpopmax(
name: bytes | str, count: int | None = None
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Pop highest scored members asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
count
|
int | None
|
Number to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of popped member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.zpopmin
async
¶
zpopmin(
name: bytes | str, count: int | None = None
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Pop lowest scored members asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
count
|
int | None
|
Number to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of popped member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.zrange
async
¶
zrange(
name: bytes | str,
start: int,
end: int,
desc: bool = False,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
byscore: bool = False,
bylex: bool = False,
offset: int | None = None,
num: int | None = None,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Get range from sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
start
|
int
|
Start index or score. |
required |
end
|
int
|
End index or score. |
required |
desc
|
bool
|
Descending order. Defaults to False. |
False
|
withscores
|
bool
|
Include scores. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Score cast function. Defaults to float. |
float
|
byscore
|
bool
|
Range by score. Defaults to False. |
False
|
bylex
|
bool
|
Range by lex. Defaults to False. |
False
|
offset
|
int | None
|
Offset for byscore/bylex. Defaults to None. |
None
|
num
|
int | None
|
Count for byscore/bylex. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.zrevrange
async
¶
zrevrange(
name: bytes | str,
start: int,
end: int,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Get reverse range from sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
start
|
int
|
Start index. |
required |
end
|
int
|
End index. |
required |
withscores
|
bool
|
Include scores. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Score cast function. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.zrangebyscore
async
¶
zrangebyscore(
name: bytes | str,
min_: float | str,
max_: float | str,
start: int | None = None,
num: int | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Get members by score range asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
min_
|
float | str
|
Minimum score. |
required |
max_
|
float | str
|
Maximum score. |
required |
start
|
int | None
|
Offset. Defaults to None. |
None
|
num
|
int | None
|
Count. Defaults to None. |
None
|
withscores
|
bool
|
Include scores. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Score cast function. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.zrank
async
¶
Get rank of member in sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
value
|
bytes | str | float
|
Member to find rank for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int | list[Any] | None
|
Rank or None if not found. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.zrem
async
¶
Remove members from sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of members removed. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.zscore
async
¶
Get score of member in sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
value
|
bytes | str | float
|
Member to get score for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
float | None
|
Score or None if not found. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.zunion
async
¶
zunion(
keys: Mapping[bytes | str, float]
| Iterable[bytes | str],
aggregate: str | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Compute the union of multiple sorted sets asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Mapping[bytes | str, float] | Iterable[bytes | str]
|
Sorted set keys, optionally mapped to per-set weights. |
required |
aggregate
|
str | None
|
"SUM", "MIN", "MAX", or "COUNT". Defaults to "SUM". |
None
|
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.zinter
async
¶
zinter(
keys: Mapping[bytes | str, float]
| Iterable[bytes | str],
aggregate: str | None = None,
withscores: bool = False,
) -> (
list[bytes | str]
| list[tuple[bytes | str, Any]]
| list[list[Any]]
)
Compute the intersection of multiple sorted sets asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Mapping[bytes | str, float] | Iterable[bytes | str]
|
Sorted set keys, optionally mapped to per-set weights. |
required |
aggregate
|
str | None
|
"SUM", "MIN", "MAX", or "COUNT". Defaults to "SUM". |
None
|
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str] | list[tuple[bytes | str, Any]] | list[list[Any]]
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.zincrby
async
¶
Increment member score in sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
amount
|
float
|
Amount to increment by. |
required |
value
|
bytes | str | float
|
Member to increment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
float | None
|
New score of the member. |
Source code in archipy/adapters/redis/adapter_mixins/sorted_sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.sscan
async
¶
sscan(
name: bytes | str,
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
) -> tuple[int, list[bytes | str]]
Scan set members incrementally asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The set key name. |
required |
cursor
|
int
|
Cursor position. Defaults to 0. |
0
|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of elements. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
tuple[int, list[bytes | str]]
|
Tuple of cursor and list of members. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.sscan_iter
async
¶
sscan_iter(
name: bytes | str,
match: bytes | str | None = None,
count: int | None = None,
) -> AsyncIterator[bytes | str]
Iterate over set members asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The set key name. |
required |
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of elements. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
AsyncIterator[bytes | str]
|
Iterator[Any]: Iterator over set members. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.sadd
async
¶
Add members to a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
*values
|
bytes | str | float
|
Members to add. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of elements added. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.scard
async
¶
Get number of members in a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of members. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.sismember
async
¶
Check if value is in set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
value
|
str
|
Value to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if value is member, False otherwise. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.smembers
async
¶
Get all members of a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
_set[bytes | str]
|
Set of all members. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.spop
async
¶
Remove and return random set members asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
count
|
int | None
|
Number of members to pop. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
bytes | float | int | str | list | None
|
bytes | float | int | str | list | None: Popped member(s) or None. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.srem
async
¶
Remove members from a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of members removed. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.sunion
async
¶
Get union of multiple sets asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
bytes | str
|
First set key. |
required |
*args
|
bytes | str
|
Additional set keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
_set[bytes | str]
|
Set containing union of all sets. |
Source code in archipy/adapters/redis/adapter_mixins/sets.py
archipy.adapters.redis.mocks.AsyncRedisMock.llen
async
¶
Get the length of a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Length of the list. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.mocks.AsyncRedisMock.lpop
async
¶
Remove and return elements from list left asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int | None
|
Number of elements to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
bytes | str | list[bytes | str] | None
|
Popped element(s) or None if list is empty. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.mocks.AsyncRedisMock.lpush
async
¶
Push elements to list left asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Length of the list after push. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.mocks.AsyncRedisMock.lrange
async
¶
Get a range of elements from a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
start
|
int
|
Start index. |
required |
end
|
int
|
End index. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
list[bytes | str]
|
List of elements in range. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.mocks.AsyncRedisMock.lrem
async
¶
Remove elements from a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int
|
Number of occurrences to remove. |
required |
value
|
str
|
Value to remove. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Number of elements removed. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.mocks.AsyncRedisMock.lset
async
¶
Set list element by index asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
index
|
int
|
Index of the element. |
required |
value
|
str
|
New value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.mocks.AsyncRedisMock.rpop
async
¶
Remove and return elements from list right asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int | None
|
Number of elements to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
bytes | str | list[bytes | str] | None
|
Popped element(s) or None if list is empty. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.mocks.AsyncRedisMock.rpush
async
¶
Push elements to list right asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
int
|
Length of the list after push. |
Source code in archipy/adapters/redis/adapter_mixins/lists.py
archipy.adapters.redis.mocks.AsyncRedisMock.pttl
async
¶
Get the time to live in milliseconds for a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Time to live in milliseconds. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.AsyncRedisMock.incrby
async
¶
Increment the integer value of a key by the given amount asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
amount
|
int
|
Amount to increment by. Defaults to 1. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
The new value after increment. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.AsyncRedisMock.increx
async
¶
increx(
name: bytes | str,
byfloat: float | None = None,
byint: int | None = None,
lbound: float | None = None,
ubound: float | None = None,
saturate: bool = False,
ex: int | timedelta | None = None,
px: int | timedelta | None = None,
exat: int | datetime | None = None,
pxat: int | datetime | None = None,
persist: bool = False,
enx: bool = False,
) -> list[Any]
Increment a windowed counter with bounds and expiration control asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to increment. |
required |
byfloat
|
float
|
Increment amount as a float. |
None
|
byint
|
int
|
Increment amount as an int. |
None
|
lbound
|
float | int
|
Lower bound for the resulting value. |
None
|
ubound
|
float | int
|
Upper bound for the resulting value. |
None
|
saturate
|
bool
|
Clamp out-of-bounds results instead of rejecting. Defaults to False. |
False
|
ex
|
int | timedelta | None
|
Expire time in seconds. |
None
|
px
|
int | timedelta | None
|
Expire time in milliseconds. |
None
|
exat
|
int | datetime | None
|
Absolute expiration time in seconds. |
None
|
pxat
|
int | datetime | None
|
Absolute expiration time in milliseconds. |
None
|
persist
|
bool
|
Remove any existing expiration. Defaults to False. |
False
|
enx
|
bool
|
Set expiration only if none already exists. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[Any]
|
A two-element list of [new_value, actual_increment_applied]. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.AsyncRedisMock.set
async
¶
set(
name: bytes | str,
value: bytes | str | float,
ex: int | timedelta | None = None,
px: int | timedelta | None = None,
nx: bool = False,
xx: bool = False,
keepttl: bool = False,
get: bool = False,
exat: int | datetime | None = None,
pxat: int | datetime | None = None,
) -> bool | str | bytes | None
Set the value of a key with optional expiration asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
value
|
int | bytes | str | float
|
The value to set. |
required |
ex
|
int | timedelta | None
|
Expire time in seconds. |
None
|
px
|
int | timedelta | None
|
Expire time in milliseconds. |
None
|
nx
|
bool
|
Only set if key doesn't exist. |
False
|
xx
|
bool
|
Only set if key exists. |
False
|
keepttl
|
bool
|
Retain the TTL from the previous value. |
False
|
get
|
bool
|
Return the old value. |
False
|
exat
|
int | datetime | None
|
Absolute expiration time in seconds. |
None
|
pxat
|
int | datetime | None
|
Absolute expiration time in milliseconds. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool | str | bytes | None
|
Result of the operation. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.AsyncRedisMock.get
async
¶
Get the value of a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value of the key or None if not exists. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.AsyncRedisMock.mget
async
¶
Get the values of multiple keys asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
bytes | str | Iterable[bytes | str]
|
Single key or iterable of keys. |
required |
*args
|
bytes | str
|
Additional keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str | None]
|
List of values. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.AsyncRedisMock.mset
async
¶
Set multiple keys to their values asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mapping
|
Mapping[bytes | str, bytes | str | float]
|
Dictionary of key-value pairs. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool
|
Always returns 'OK'. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.AsyncRedisMock.keys
async
¶
Find all keys matching the pattern asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
bytes | str
|
Pattern to match keys against. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
list[bytes | str]
|
List of matching keys. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.AsyncRedisMock.getset
async
¶
Set a key's value and return its old value asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key name. |
required |
value
|
bytes | str | float
|
The new value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The previous value or None. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.AsyncRedisMock.getdel
async
¶
Get a key's value and delete it asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str | None
|
The value of the key or None. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.AsyncRedisMock.exists
async
¶
Check if keys exist asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of keys that exist. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.AsyncRedisMock.delete
async
¶
Delete keys asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Number of keys deleted. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.AsyncRedisMock.append
async
¶
Append a value to a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key name. |
required |
value
|
bytes | str | float
|
The value to append. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Length of the string after append. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.AsyncRedisMock.ttl
async
¶
Get the time to live in seconds for a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
int
|
Time to live in seconds. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.AsyncRedisMock.type
async
¶
Determine the type stored at key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bytes | str
|
Type of the key's value. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.AsyncRedisMock.scan
async
¶
scan(
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> tuple[int, list[bytes | str]]
Scan keys in database incrementally asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cursor
|
int
|
Cursor position. Defaults to 0. |
0
|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of keys. Defaults to None. |
None
|
_type
|
str | None
|
Filter by type. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
tuple[int, list[bytes | str]]
|
Tuple of cursor and list of keys. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.AsyncRedisMock.scan_iter
async
¶
scan_iter(
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> AsyncIterator[bytes | str]
Iterate over keys in database asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of keys. Defaults to None. |
None
|
_type
|
str | None
|
Filter by type. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
AsyncIterator[bytes | str]
|
Iterator[Any]: Iterator over matching keys. |
Source code in archipy/adapters/redis/adapter_mixins/keys.py
archipy.adapters.redis.mocks.AsyncRedisMock.cluster_info
async
¶
Get cluster information asynchronously.
archipy.adapters.redis.mocks.AsyncRedisMock.cluster_nodes
async
¶
cluster_nodes() -> (
dict[
str,
dict[
str,
str
| bool
| list[list[str]]
| list[dict[str, str]],
],
]
| None
)
Get cluster nodes information asynchronously.
Source code in archipy/adapters/redis/adapter_mixins/cluster.py
archipy.adapters.redis.mocks.AsyncRedisMock.cluster_slots
async
¶
Get cluster slots mapping asynchronously.
archipy.adapters.redis.mocks.AsyncRedisMock.cluster_key_slot
async
¶
Get the hash slot for a key asynchronously.
archipy.adapters.redis.mocks.AsyncRedisMock.cluster_count_keys_in_slot
async
¶
Count keys in a specific slot asynchronously.
Source code in archipy/adapters/redis/adapter_mixins/cluster.py
archipy.adapters.redis.mocks.AsyncRedisMock.cluster_get_keys_in_slot
async
¶
Get keys in a specific slot asynchronously.
Source code in archipy/adapters/redis/adapter_mixins/cluster.py
archipy.adapters.redis.mocks.AsyncRedisMock.ping
async
¶
Ping the Redis server asynchronously.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
bool
|
'PONG' if successful. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.mocks.AsyncRedisMock.flushdb
async
¶
Delete all keys in the current database asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asynchronous
|
bool
|
Whether Redis should flush asynchronously. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.mocks.AsyncRedisMock.get_pipeline
async
¶
get_pipeline(
transaction: Any = True, shard_hint: Any = None
) -> AsyncPipeline | AsyncClusterPipeline
Get pipeline for multiple commands asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transaction
|
Any
|
Use transactions. Defaults to True. |
True
|
shard_hint
|
Any
|
Sharding hint. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Pipeline | ClusterPipeline
|
AsyncPipeline | AsyncClusterPipeline: Pipeline object. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.mocks.AsyncRedisMock.config_set
async
¶
Set a Redis server configuration parameter asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The configuration parameter name. |
required |
value
|
str
|
The value to set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.mocks.AsyncRedisMock.config_get
async
¶
Get Redis server configuration parameters matching a pattern asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
str
|
Pattern to match configuration parameter names. Defaults to "*". |
'*'
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
dict[str, str]
|
Dictionary of configuration parameter names to values. |
Source code in archipy/adapters/redis/adapter_mixins/connection.py
archipy.adapters.redis.mocks.AsyncRedisMock.search_index ¶
Return an index-bound async RediSearch handle.
archipy.adapters.redis.mocks.AsyncRedisMock.list_search_indexes
async
¶
List RediSearch indexes available on the server asynchronously.
options: show_root_toc_entry: false heading_level: 3