rapyer


Namerapyer JSON
Version 0.0.4 PyPI version JSON
download
home_pageNone
SummaryPydantic models with Redis as the backend
upload_time2025-10-20 06:16:44
maintainerNone
docs_urlNone
authorYedidyaHKfir
requires_python<4.0,>=3.10
licenseMIT
keywords redis pydantic orm database async
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
  <img src="icon.png" alt="Rapyer Logo" width="120">
  
  # Rapyer
  
  **Redis Atomic Pydantic Engine Reactor**
  
  *An async Redis ORM that provides atomic operations for complex data models*
  
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
  [![Redis](https://img.shields.io/badge/redis-6.0+-red.svg)](https://redis.io/)
  
  📚 **[Full Documentation](https://yedidyakfir.github.io/rapyer/)** | [Installation](https://yedidyakfir.github.io/rapyer/installation/) | [Examples](https://yedidyakfir.github.io/rapyer/examples/) | [API Reference](https://yedidyakfir.github.io/rapyer/api/)
</div>

---

## What is Rapyer?

Rapyer (**R**edis **A**tomic **Py**dantic **E**ngine **R**eactor) is a modern async Redis ORM that enables atomic operations on complex data models. Built with Pydantic v2, it provides type-safe Redis interactions while maintaining data consistency and preventing race conditions.

### Key Features

🚀 **Atomic Operations** - Built-in atomic updates for complex Redis data structures  
⚡ **Async/Await** - Full asyncio support for high-performance applications  
🔒 **Type Safety** - Complete type validation using Pydantic v2  
🌐 **Universal Types** - Native optimization for primitives, automatic serialization for complex types  
🔄 **Race Condition Safe** - Lock context managers and pipeline operations  
📦 **Redis JSON** - Efficient storage using Redis JSON with support for nested structures

## Installation

```bash
pip install rapyer
```

**Requirements:**
- Python 3.10+
- Redis server with JSON module
- Pydantic v2

## Quick Start

```python
import asyncio
from rapyer.base import AtomicRedisModel
from typing import List, Dict

class User(AtomicRedisModel):
    name: str
    age: int
    tags: List[str] = []
    metadata: Dict[str, str] = {}

async def main():
    # Create and save a user
    user = User(name="John", age=30)
    await user.save()

    # Atomic operations that prevent race conditions
    await user.tags.aappend("python")
    await user.tags.aextend(["redis", "pydantic"])
    await user.metadata.aupdate(role="developer", level="senior")

    # Load user from Redis
    loaded_user = await User.get(user.key)
    print(f"User: {loaded_user.name}, Tags: {loaded_user.tags}")

    # Atomic operations with locks for complex updates
    async with user.lock("update_profile") as locked_user:
        locked_user.age += 1
        await locked_user.tags.aappend("experienced")
        # Changes saved atomically when context exits

if __name__ == "__main__":
    asyncio.run(main())
```

## Core Concepts

### Atomic Operations
Rapyer ensures data consistency with built-in atomic operations:

```python
# These operations are atomic and race-condition safe
await user.tags.aappend("python")           # Add to list
await user.metadata.aupdate(role="dev")     # Update dict
await user.score.set(100)                   # Set value
```

### Lock Context Manager
For complex multi-field updates:

```python
async with user.lock("transaction") as locked_user:
    locked_user.balance -= 50
    locked_user.transaction_count += 1
    # All changes saved atomically
```

### Pipeline Operations
Batch multiple operations for performance:

```python
async with user.pipeline() as pipelined_user:
    await pipelined_user.tags.aappend("redis")
    await pipelined_user.metadata.aupdate(level="senior")
    # Executed as single atomic transaction
```

## Type Support

Rapyer supports all Python types with automatic serialization:

- **Native types** (`str`, `int`, `List`, `Dict`) - Optimized Redis operations
- **Complex types** (`dataclass`, `Enum`, `Union`) - Automatic pickle serialization  
- **Nested models** - Full Redis functionality preserved

```python
from dataclasses import dataclass
from enum import Enum

@dataclass
class Config:
    debug: bool = False

class User(AtomicRedisModel):
    name: str = "default"
    scores: List[int] = []
    config: Config = Config()  # Auto-serialized
    
# All types work identically
user = User()
await user.config.set(Config(debug=True))  # Automatic serialization
await user.scores.aappend(95)               # Native Redis operation
```

## Why Rapyer?

### Race Condition Prevention
Traditional Redis operations can lead to data inconsistency in concurrent environments. Rapyer solves this with atomic operations and lock management.

### Developer Experience  
- **Type Safety**: Full Pydantic v2 validation
- **Async/Await**: Native asyncio support
- **Intuitive API**: Pythonic Redis operations

### Performance
- **Pipeline Operations**: Batch multiple operations
- **Native Type Optimization**: Efficient Redis storage
- **Connection Pooling**: Built-in Redis connection management

## Learn More

- 📖 **[Documentation](https://yedidyakfir.github.io/rapyer/)** - Complete guide and API reference
- 🚀 **[Examples](https://yedidyakfir.github.io/rapyer/examples/)** - Real-world usage patterns  
- ⚡ **[Advanced Features](https://yedidyakfir.github.io/rapyer/advanced/)** - Locks, pipelines, and nested models

---

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

MIT License

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "rapyer",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "redis, pydantic, orm, database, async",
    "author": "YedidyaHKfir",
    "author_email": "your.email@example.com",
    "download_url": "https://files.pythonhosted.org/packages/de/ad/ba37d3743e5d7162a545c3a7435889f63d27827768f57379c68caf475096/rapyer-0.0.4.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n  <img src=\"icon.png\" alt=\"Rapyer Logo\" width=\"120\">\n  \n  # Rapyer\n  \n  **Redis Atomic Pydantic Engine Reactor**\n  \n  *An async Redis ORM that provides atomic operations for complex data models*\n  \n  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)\n  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n  [![Redis](https://img.shields.io/badge/redis-6.0+-red.svg)](https://redis.io/)\n  \n  \ud83d\udcda **[Full Documentation](https://yedidyakfir.github.io/rapyer/)** | [Installation](https://yedidyakfir.github.io/rapyer/installation/) | [Examples](https://yedidyakfir.github.io/rapyer/examples/) | [API Reference](https://yedidyakfir.github.io/rapyer/api/)\n</div>\n\n---\n\n## What is Rapyer?\n\nRapyer (**R**edis **A**tomic **Py**dantic **E**ngine **R**eactor) is a modern async Redis ORM that enables atomic operations on complex data models. Built with Pydantic v2, it provides type-safe Redis interactions while maintaining data consistency and preventing race conditions.\n\n### Key Features\n\n\ud83d\ude80 **Atomic Operations** - Built-in atomic updates for complex Redis data structures  \n\u26a1 **Async/Await** - Full asyncio support for high-performance applications  \n\ud83d\udd12 **Type Safety** - Complete type validation using Pydantic v2  \n\ud83c\udf10 **Universal Types** - Native optimization for primitives, automatic serialization for complex types  \n\ud83d\udd04 **Race Condition Safe** - Lock context managers and pipeline operations  \n\ud83d\udce6 **Redis JSON** - Efficient storage using Redis JSON with support for nested structures\n\n## Installation\n\n```bash\npip install rapyer\n```\n\n**Requirements:**\n- Python 3.10+\n- Redis server with JSON module\n- Pydantic v2\n\n## Quick Start\n\n```python\nimport asyncio\nfrom rapyer.base import AtomicRedisModel\nfrom typing import List, Dict\n\nclass User(AtomicRedisModel):\n    name: str\n    age: int\n    tags: List[str] = []\n    metadata: Dict[str, str] = {}\n\nasync def main():\n    # Create and save a user\n    user = User(name=\"John\", age=30)\n    await user.save()\n\n    # Atomic operations that prevent race conditions\n    await user.tags.aappend(\"python\")\n    await user.tags.aextend([\"redis\", \"pydantic\"])\n    await user.metadata.aupdate(role=\"developer\", level=\"senior\")\n\n    # Load user from Redis\n    loaded_user = await User.get(user.key)\n    print(f\"User: {loaded_user.name}, Tags: {loaded_user.tags}\")\n\n    # Atomic operations with locks for complex updates\n    async with user.lock(\"update_profile\") as locked_user:\n        locked_user.age += 1\n        await locked_user.tags.aappend(\"experienced\")\n        # Changes saved atomically when context exits\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n## Core Concepts\n\n### Atomic Operations\nRapyer ensures data consistency with built-in atomic operations:\n\n```python\n# These operations are atomic and race-condition safe\nawait user.tags.aappend(\"python\")           # Add to list\nawait user.metadata.aupdate(role=\"dev\")     # Update dict\nawait user.score.set(100)                   # Set value\n```\n\n### Lock Context Manager\nFor complex multi-field updates:\n\n```python\nasync with user.lock(\"transaction\") as locked_user:\n    locked_user.balance -= 50\n    locked_user.transaction_count += 1\n    # All changes saved atomically\n```\n\n### Pipeline Operations\nBatch multiple operations for performance:\n\n```python\nasync with user.pipeline() as pipelined_user:\n    await pipelined_user.tags.aappend(\"redis\")\n    await pipelined_user.metadata.aupdate(level=\"senior\")\n    # Executed as single atomic transaction\n```\n\n## Type Support\n\nRapyer supports all Python types with automatic serialization:\n\n- **Native types** (`str`, `int`, `List`, `Dict`) - Optimized Redis operations\n- **Complex types** (`dataclass`, `Enum`, `Union`) - Automatic pickle serialization  \n- **Nested models** - Full Redis functionality preserved\n\n```python\nfrom dataclasses import dataclass\nfrom enum import Enum\n\n@dataclass\nclass Config:\n    debug: bool = False\n\nclass User(AtomicRedisModel):\n    name: str = \"default\"\n    scores: List[int] = []\n    config: Config = Config()  # Auto-serialized\n    \n# All types work identically\nuser = User()\nawait user.config.set(Config(debug=True))  # Automatic serialization\nawait user.scores.aappend(95)               # Native Redis operation\n```\n\n## Why Rapyer?\n\n### Race Condition Prevention\nTraditional Redis operations can lead to data inconsistency in concurrent environments. Rapyer solves this with atomic operations and lock management.\n\n### Developer Experience  \n- **Type Safety**: Full Pydantic v2 validation\n- **Async/Await**: Native asyncio support\n- **Intuitive API**: Pythonic Redis operations\n\n### Performance\n- **Pipeline Operations**: Batch multiple operations\n- **Native Type Optimization**: Efficient Redis storage\n- **Connection Pooling**: Built-in Redis connection management\n\n## Learn More\n\n- \ud83d\udcd6 **[Documentation](https://yedidyakfir.github.io/rapyer/)** - Complete guide and API reference\n- \ud83d\ude80 **[Examples](https://yedidyakfir.github.io/rapyer/examples/)** - Real-world usage patterns  \n- \u26a1 **[Advanced Features](https://yedidyakfir.github.io/rapyer/advanced/)** - Locks, pipelines, and nested models\n\n---\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nMIT License\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Pydantic models with Redis as the backend",
    "version": "0.0.4",
    "project_urls": {
        "Documentation": "https://github.com/YedidyaHKfir/rapyer",
        "Homepage": "https://github.com/YedidyaHKfir/rapyer",
        "Repository": "https://github.com/YedidyaHKfir/rapyer"
    },
    "split_keywords": [
        "redis",
        " pydantic",
        " orm",
        " database",
        " async"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b382622ec88940291c2a0b513f3474bd7fcb002d167b8a58320239cfc5e1adcb",
                "md5": "0cc68f9e76cfad2c8b6a5a4698360579",
                "sha256": "49f7c89b4680765347b8d1cb884b70660f83de59dafea07e3dcd113243061ec9"
            },
            "downloads": -1,
            "filename": "rapyer-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0cc68f9e76cfad2c8b6a5a4698360579",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 18540,
            "upload_time": "2025-10-20T06:16:43",
            "upload_time_iso_8601": "2025-10-20T06:16:43.487197Z",
            "url": "https://files.pythonhosted.org/packages/b3/82/622ec88940291c2a0b513f3474bd7fcb002d167b8a58320239cfc5e1adcb/rapyer-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "deadba37d3743e5d7162a545c3a7435889f63d27827768f57379c68caf475096",
                "md5": "967af8239b17da8633b84a5ac8588fd4",
                "sha256": "a3b026acf074638392941976e5768fc836bc4e629b7b1dd1c3305265c8380db7"
            },
            "downloads": -1,
            "filename": "rapyer-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "967af8239b17da8633b84a5ac8588fd4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 14104,
            "upload_time": "2025-10-20T06:16:44",
            "upload_time_iso_8601": "2025-10-20T06:16:44.261000Z",
            "url": "https://files.pythonhosted.org/packages/de/ad/ba37d3743e5d7162a545c3a7435889f63d27827768f57379c68caf475096/rapyer-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-20 06:16:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "YedidyaHKfir",
    "github_project": "rapyer",
    "github_not_found": true,
    "lcname": "rapyer"
}
        
Elapsed time: 3.24484s