RedisKeyValueStoreClient
Hierarchy
- RedisClientMixin
- KeyValueStoreClient
- RedisKeyValueStoreClient
Index
Methods
__init__
Initialize a new instance.
Preferably use the
RedisKeyValueStoreClient.openclass method to create a new instance.Parameters
storage_name: str
storage_id: str
redis: Redis
Returns None
delete_value
Delete a value from the key-value store by its key.
The backend method for the
KeyValueStore.delete_valuecall.Parameters
keyword-onlykey: str
Returns None
drop
Drop the whole key-value store and remove all its values.
The backend method for the
KeyValueStore.dropcall.Returns None
get_metadata
Get the metadata of the key-value store.
Returns KeyValueStoreMetadata
get_public_url
Get the public URL for the given key.
The backend method for the
KeyValueStore.get_public_urlcall.Parameters
keyword-onlykey: str
Returns str
get_value
Retrieve the given record from the key-value store.
The backend method for the
KeyValueStore.get_valuecall.Parameters
keyword-onlykey: str
Returns KeyValueStoreRecord | None
iterate_keys
Iterate over all the existing keys in the key-value store.
The backend method for the
KeyValueStore.iterate_keyscall.Parameters
optionalkeyword-onlyexclusive_start_key: str | None = None
optionalkeyword-onlylimit: int | None = None
Returns AsyncIterator[KeyValueStoreRecordMetadata]
open
Open or create a new Redis key-value store client.
This method attempts to open an existing key-value store from the Redis database. If a store with the specified ID or name exists, it loads the metadata from the database. If no existing store is found, a new one is created.
Parameters
keyword-onlyid: str | None
The ID of the key-value store. If not provided, a random ID will be generated.
keyword-onlyname: str | None
The name of the key-value store for named (global scope) storages.
keyword-onlyalias: str | None
The alias of the key-value store for unnamed (run scope) storages.
keyword-onlyredis: Redis
Redis client instance.
Returns RedisKeyValueStoreClient
purge
Purge all items from the key-value store.
The backend method for the
KeyValueStore.purgecall.Returns None
record_exists
Check if a record with the given key exists in the key-value store.
The backend method for the
KeyValueStore.record_existscall.Parameters
keyword-onlykey: str
The key to check for existence.
Returns bool
set_value
Set a value in the key-value store by its key.
The backend method for the
KeyValueStore.set_valuecall.Parameters
keyword-onlykey: str
keyword-onlyvalue: Any
optionalkeyword-onlycontent_type: str | None = None
Returns None
Properties
metadata_key
Return the Redis key for the metadata of this storage.
redis
Return the Redis client instance.
Redis implementation of the key-value store client.
This client persists key-value data to Redis using hash data structures for efficient storage and retrieval. Keys are mapped to values with automatic content type detection and size tracking for metadata management.
The key-value store data is stored in Redis using the following key pattern:
key_value_stores:{name}:items- Redis hash containing key-value pairs (values stored as binary data).key_value_stores:{name}:metadata_items- Redis hash containing metadata for each key.key_value_stores:{name}:metadata- Redis JSON object containing store metadata.Values are serialized based on their type: JSON objects are stored as UTF-8 encoded JSON strings, text values as UTF-8 encoded strings, and binary data as-is. The implementation automatically handles content type detection and maintains metadata about each record including size and MIME type information.
All operations are atomic through Redis hash operations and pipeline transactions. The client supports concurrent access through Redis's built-in atomic operations for hash fields.