Skip to main content

No project description provided

Project description

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

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())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typed_redis-0.0.2.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

typed_redis-0.0.2-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file typed_redis-0.0.2.tar.gz.

File metadata

  • Download URL: typed_redis-0.0.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.10.11 Darwin/24.5.0

File hashes

Hashes for typed_redis-0.0.2.tar.gz
Algorithm Hash digest
SHA256 42308adf1d4809396b26ae4b747e45072b5cd71264421ac9c335698e5c353620
MD5 5061320202df132c3b0e9eeb55ba7959
BLAKE2b-256 514c9678e4dbcad11094657d7bd31849a2029e715746fa565bedeae1dd4502a1

See more details on using hashes here.

File details

Details for the file typed_redis-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: typed_redis-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.10.11 Darwin/24.5.0

File hashes

Hashes for typed_redis-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e85c551f9ca0966476e807943c80cda9860564b0d39f70159c29e07c8f87f46c
MD5 9d8323ad8d72965353bd4f103e33c5da
BLAKE2b-256 714f6e9eb5899148772c551620c4a7f372eab0c9d7b30786efa58eaae1583035

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page