RedisDatasetClient
Hierarchy
- RedisClientMixin
- DatasetClient
- RedisDatasetClient
Index
Methods
__init__
Initialize a new instance.
Preferably use the
RedisDatasetClient.openclass method to create a new instance.Parameters
storage_name: str
Internal storage name used for Redis keys.
storage_id: str
Unique identifier for the dataset.
redis: Redis
Redis client instance.
Returns None
drop
Drop the whole dataset and remove all its items.
The backend method for the
Dataset.dropcall.Returns None
get_data
Get data from the dataset with various filtering options.
The backend method for the
Dataset.get_datacall.Parameters
optionalkeyword-onlyoffset: int = 0
optionalkeyword-onlylimit: int | None = 999_999_999_999
optionalkeyword-onlyclean: bool = False
optionalkeyword-onlydesc: bool = False
optionalkeyword-onlyfields: list[str] | None = None
optionalkeyword-onlyomit: list[str] | None = None
optionalkeyword-onlyunwind: list[str] | None = None
optionalkeyword-onlyskip_empty: bool = False
optionalkeyword-onlyskip_hidden: bool = False
optionalkeyword-onlyflatten: list[str] | None = None
optionalkeyword-onlyview: str | None = None
Returns DatasetItemsListPage
get_metadata
Get the metadata of the dataset.
Returns DatasetMetadata
iterate_items
Iterate over dataset items one by one.
This method yields items individually instead of loading all items at once, which is more memory efficient for large datasets.
Parameters
optionalkeyword-onlyoffset: int = 0
optionalkeyword-onlylimit: int | None = None
optionalkeyword-onlyclean: bool = False
optionalkeyword-onlydesc: bool = False
optionalkeyword-onlyfields: list[str] | None = None
optionalkeyword-onlyomit: list[str] | None = None
optionalkeyword-onlyunwind: list[str] | None = None
optionalkeyword-onlyskip_empty: bool = False
optionalkeyword-onlyskip_hidden: bool = False
Returns AsyncIterator[dict[str, Any]]
open
Open or create a new Redis dataset client.
This method attempts to open an existing dataset from the Redis database. If a dataset 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 dataset. If not provided, a random ID will be generated.
keyword-onlyname: str | None
The name of the dataset for named (global scope) storages.
keyword-onlyalias: str | None
The alias of the dataset for unnamed (run scope) storages.
keyword-onlyredis: Redis
Redis client instance.
Returns RedisDatasetClient
purge
Purge all items from the dataset.
The backend method for the
Dataset.purgecall.Returns None
push_data
Push data to the dataset.
The backend method for the
Dataset.push_datacall.Parameters
data: list[Any] | dict[str, Any]
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 dataset client.
This client persists dataset items to Redis using JSON arrays for efficient storage and retrieval. Items are stored as JSON objects with automatic ordering preservation through Redis list operations.
The dataset data is stored in Redis using the following key pattern:
datasets:{name}:items- Redis JSON array containing all dataset items.datasets:{name}:metadata- Redis JSON object containing dataset metadata.Items must be JSON-serializable dictionaries. Single items or lists of items can be pushed to the dataset. The item ordering is preserved through Redis JSON array operations. All operations provide atomic consistency through Redis transactions and pipeline operations.