Async Redis ORM for Python
Project description
ashredis - Redis Object Storage Library
Overview
Python library for Redis object storage with async interface.
Installation
pip install ashredis
Basic Usage Example
import asyncio
from dataclasses import dataclass
from typing import Optional
from ashredis import RedisObject, RedisParams, RecordBase, MISSING
# Define data model
@dataclass
class User(RecordBase):
username: Optional[str] = MISSING
email: Optional[str] = MISSING
age: Optional[int] = MISSING
async def main():
# Configure Redis connection
redis_params = RedisParams(
host="localhost",
port=6379,
password="",
db=0
)
# Create RedisObject instance
async with RedisObject(redis_params=redis_params) as redis_obj:
# Create and save object
user = User(
username="test_user",
email="user@example.com",
age=30
)
# Save object to Redis
await redis_obj.save(record=user, key="user_1")
# Load object from Redis
loaded_user = await redis_obj.load(record_type=User, key="user_1")
print(f"Loaded user: {loaded_user.username}, {loaded_user.email}")
# Update object
loaded_user.age = 31
await redis_obj.save(record=loaded_user, key="user_1")
# Delete object
await redis_obj.delete(record_type=User, key="user_1")
if __name__ == "__main__":
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ashredis-1.2.5.tar.gz
(8.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ashredis-1.2.5.tar.gz.
File metadata
- Download URL: ashredis-1.2.5.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01e944058c0f26aee03f2bdc2532aef473027634280508e57d29fb6d20fb9002
|
|
| MD5 |
c442160cf0bcfb517c52cab61486edd9
|
|
| BLAKE2b-256 |
a5f177c5b0ecdb77105580bdabefc17d86e8f09c435e89bc010700c92acf4be1
|
File details
Details for the file ashredis-1.2.5-py3-none-any.whl.
File metadata
- Download URL: ashredis-1.2.5-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f12388647a3b7f5fe2411dc3f5f23363732daa382c8e174036127f4947f2ad4b
|
|
| MD5 |
c3a59555a9c71145a44b4f2799acad8b
|
|
| BLAKE2b-256 |
a79d315c8c6172dab6bc90da1676370e99124e7bfd818886246d0f833f1d1e1e
|