Metadata-Version: 2.3
Name: typed-redis
Version: 0.0.2
Summary: 
License: MIT
Author: Julien Kmec
Author-email: me@julien.dev
Requires-Python: >=3.10,<3.13
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Provides-Extra: dev
Requires-Dist: black (>=24.0) ; extra == "dev"
Requires-Dist: coverage (>=7.6) ; extra == "dev"
Requires-Dist: fakeredis (>=2.30.3,<3.0.0)
Requires-Dist: pydantic (>=2.11.7,<3.0.0)
Requires-Dist: pytest (>=8.0) ; extra == "dev"
Requires-Dist: pytest-asyncio (>=0.23) ; extra == "dev"
Requires-Dist: pytest-cov (>=6.1.1,<7.0.0) ; extra == "dev"
Requires-Dist: redis (>=6.4.0,<7.0.0)
Description-Content-Type: text/markdown

# Typed Redis for Python

This repository allows you to create Pydantic models representing Redis objects.

The Redis models are async and follow an ORM-like syntax.

## Example

```python

import asyncio
import json
from typed_redis import Store
from redis.asyncio import Redis

redis = Redis(...)

class User(Store(redis)):
    """User model."""

    id: int
    name: str

    @property
    def redis_key(self) -> str:
        return f"user:{self.id}"

async def main():
    """Main function."""

    user = User(id=1, name="Charlie")

    await user() # or: await user.create()

    print(await redis.get("user:1")) # JSON representation of the user

    # Now let's update the user:
    await user.update(name="Bob")

    json_model = json.loads(await redis.get("user:1"))

    print(json_model["name"]) # Bob



asyncio.run(main())

```
