Skip to main content

Async Redis ORM for Python

Project description

ashredis - Redis Object Storage Library

PyPI version Python versions

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


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.3.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

ashredis-1.2.3-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file ashredis-1.2.3.tar.gz.

File metadata

  • Download URL: ashredis-1.2.3.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for ashredis-1.2.3.tar.gz
Algorithm Hash digest
SHA256 732acc335133d6b3be17c34489a63c8ddd393774d4357d3f5673558b8977d134
MD5 79ee1b0a95d55d149e3a576e72c93e6f
BLAKE2b-256 f3dc3e273850ab604d07ffd4f0afd71365cf8b54b8759084574c4c250f8c6e6f

See more details on using hashes here.

File details

Details for the file ashredis-1.2.3-py3-none-any.whl.

File metadata

  • Download URL: ashredis-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for ashredis-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8da7e76f3e4321523e36240c064ca6f7693289bf521428ada0e688a5f0345aed
MD5 f7e5149a5a72bc7d31a0aa5bbb6fd674
BLAKE2b-256 b0795cba45b147bf39c8afa088d3bbfbe997635de606f73e179b3ba18c04133f

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