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.4.tar.gz (8.6 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.4-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ashredis-1.2.4.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

Hashes for ashredis-1.2.4.tar.gz
Algorithm Hash digest
SHA256 94f276257dd0e2278117362f5e7f45a352562c804dc633dc911fd4ab909021a7
MD5 09a10a986c174b2de0ad2ac773e8c1d0
BLAKE2b-256 e312ff474838def7a908c121b2264d5222a2bbd920072e2ebde55069a9383ef1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ashredis-1.2.4-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

Hashes for ashredis-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f15335f224338e53324f3fdda64e6d51fe96e18bfe060069612b9473dd5d750f
MD5 92ceb41150d28c908cfceb175d008594
BLAKE2b-256 fa93883107d5623c2ecacd350c55f4adf79605d2a9e4f7a19d56189e453a677e

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