Skip to main content

Simple redis storage for pydantic objects with an interface of the MutableMapping.

Project description

redantic

License: MIT

Simple redis storage for pydantic objects with an interface of the MutableMapping.

Examples

from redantic import RedisDict
from pydantic import BaseModel
from redis import Redis

class Car(BaseModel):
    price: float
    model: str

CarId = int

client = Redis()
d = RedisDict[CarId, Car](client=client, name='car_collection', key_type=CarId, value_type=Car)
d[1] = Car(price=100.5, model='a')
d[2] = Car(price=200, model='b')

print(len(d))
for i in d:
    print(d[i])

You can also use pydantic object as a key.

class CarId(BaseModel):
    id: int
    type: str

d[CarId(id=1, type='some_type')] = Car(price=100.5, model='a')

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

redantic-0.1.1.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.

redantic-0.1.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file redantic-0.1.1.tar.gz.

File metadata

  • Download URL: redantic-0.1.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Linux/5.15.0-1022-azure

File hashes

Hashes for redantic-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9ff262364e8bfbd54e1f1444ab857896c5f7e2d2c61983480cd90a89a8dc8ffb
MD5 6d64da078870704e1603d2472f6d14fe
BLAKE2b-256 2eb0c5cea7cdc1731978016178dda9769ad220152eed2a9e77bea8b13ee0fd68

See more details on using hashes here.

File details

Details for the file redantic-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: redantic-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Linux/5.15.0-1022-azure

File hashes

Hashes for redantic-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d5d179fb92bbb38f5538f24e57a0fb2be8dfe5acc18e8078295a19f24a7dc65e
MD5 170cd5c9df60f3b212825f20b401acde
BLAKE2b-256 a2f670596e3c45fe27cc4fa137f46e47326b66292f0c7bdcf0a1ceaf64610e2c

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