rapyer 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rapyer-0.0.1/PKG-INFO +195 -0
- rapyer-0.0.1/README.md +168 -0
- rapyer-0.0.1/pyproject.toml +39 -0
- rapyer-0.0.1/rapyer/__init__.py +6 -0
- rapyer-0.0.1/rapyer/base.py +311 -0
- rapyer-0.0.1/rapyer/config.py +28 -0
- rapyer-0.0.1/rapyer/context.py +12 -0
- rapyer-0.0.1/rapyer/errors/__init__.py +0 -0
- rapyer-0.0.1/rapyer/errors/base.py +10 -0
- rapyer-0.0.1/rapyer/py.typed +0 -0
- rapyer-0.0.1/rapyer/types/__init__.py +0 -0
- rapyer-0.0.1/rapyer/types/any.py +57 -0
- rapyer-0.0.1/rapyer/types/base.py +99 -0
- rapyer-0.0.1/rapyer/types/boolean.py +46 -0
- rapyer-0.0.1/rapyer/types/byte.py +53 -0
- rapyer-0.0.1/rapyer/types/datetime.py +63 -0
- rapyer-0.0.1/rapyer/types/dct.py +245 -0
- rapyer-0.0.1/rapyer/types/init.py +60 -0
- rapyer-0.0.1/rapyer/types/integer.py +53 -0
- rapyer-0.0.1/rapyer/types/lst.py +149 -0
- rapyer-0.0.1/rapyer/types/string.py +44 -0
- rapyer-0.0.1/rapyer/types/utils.py +7 -0
- rapyer-0.0.1/rapyer/utils.py +58 -0
rapyer-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rapyer
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Pydantic models with Redis as the backend
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: redis,pydantic,orm,database,async
|
|
7
|
+
Author: YedidyaHKfir
|
|
8
|
+
Author-email: your.email@example.com
|
|
9
|
+
Requires-Python: >=3.10,<4.0
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Database
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Dist: pydantic (>=2.11.9)
|
|
22
|
+
Requires-Dist: redis[async] (>=6.4.0)
|
|
23
|
+
Project-URL: Documentation, https://github.com/YedidyaHKfir/rapyer
|
|
24
|
+
Project-URL: Homepage, https://github.com/YedidyaHKfir/rapyer
|
|
25
|
+
Project-URL: Repository, https://github.com/YedidyaHKfir/rapyer
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
<div align="center">
|
|
29
|
+
<img src="icon.png" alt="Rapyer Logo" width="120">
|
|
30
|
+
|
|
31
|
+
# Rapyer
|
|
32
|
+
|
|
33
|
+
**Redis Atomic Pydantic Engine Reactor**
|
|
34
|
+
|
|
35
|
+
*An async Redis ORM that provides atomic operations for complex data models*
|
|
36
|
+
|
|
37
|
+
[](https://www.python.org/downloads/)
|
|
38
|
+
[](https://opensource.org/licenses/MIT)
|
|
39
|
+
[](https://redis.io/)
|
|
40
|
+
|
|
41
|
+
📚 **[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/)
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## What is Rapyer?
|
|
47
|
+
|
|
48
|
+
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.
|
|
49
|
+
|
|
50
|
+
### Key Features
|
|
51
|
+
|
|
52
|
+
🚀 **Atomic Operations** - Built-in atomic updates for complex Redis data structures
|
|
53
|
+
⚡ **Async/Await** - Full asyncio support for high-performance applications
|
|
54
|
+
🔒 **Type Safety** - Complete type validation using Pydantic v2
|
|
55
|
+
🌐 **Universal Types** - Native optimization for primitives, automatic serialization for complex types
|
|
56
|
+
🔄 **Race Condition Safe** - Lock context managers and pipeline operations
|
|
57
|
+
📦 **Redis JSON** - Efficient storage using Redis JSON with support for nested structures
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install rapyer
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Requirements:**
|
|
66
|
+
- Python 3.10+
|
|
67
|
+
- Redis server with JSON module
|
|
68
|
+
- Pydantic v2
|
|
69
|
+
|
|
70
|
+
## Quick Start
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import asyncio
|
|
74
|
+
from rapyer.base import AtomicRedisModel
|
|
75
|
+
from typing import List, Dict
|
|
76
|
+
|
|
77
|
+
class User(AtomicRedisModel):
|
|
78
|
+
name: str
|
|
79
|
+
age: int
|
|
80
|
+
tags: List[str] = []
|
|
81
|
+
metadata: Dict[str, str] = {}
|
|
82
|
+
|
|
83
|
+
async def main():
|
|
84
|
+
# Create and save a user
|
|
85
|
+
user = User(name="John", age=30)
|
|
86
|
+
await user.save()
|
|
87
|
+
|
|
88
|
+
# Atomic operations that prevent race conditions
|
|
89
|
+
await user.tags.aappend("python")
|
|
90
|
+
await user.tags.aextend(["redis", "pydantic"])
|
|
91
|
+
await user.metadata.aupdate(role="developer", level="senior")
|
|
92
|
+
|
|
93
|
+
# Load user from Redis
|
|
94
|
+
loaded_user = await User.get(user.key)
|
|
95
|
+
print(f"User: {loaded_user.name}, Tags: {loaded_user.tags}")
|
|
96
|
+
|
|
97
|
+
# Atomic operations with locks for complex updates
|
|
98
|
+
async with user.lock("update_profile") as locked_user:
|
|
99
|
+
locked_user.age += 1
|
|
100
|
+
await locked_user.tags.aappend("experienced")
|
|
101
|
+
# Changes saved atomically when context exits
|
|
102
|
+
|
|
103
|
+
if __name__ == "__main__":
|
|
104
|
+
asyncio.run(main())
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Core Concepts
|
|
108
|
+
|
|
109
|
+
### Atomic Operations
|
|
110
|
+
Rapyer ensures data consistency with built-in atomic operations:
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
# These operations are atomic and race-condition safe
|
|
114
|
+
await user.tags.aappend("python") # Add to list
|
|
115
|
+
await user.metadata.aupdate(role="dev") # Update dict
|
|
116
|
+
await user.score.set(100) # Set value
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Lock Context Manager
|
|
120
|
+
For complex multi-field updates:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
async with user.lock("transaction") as locked_user:
|
|
124
|
+
locked_user.balance -= 50
|
|
125
|
+
locked_user.transaction_count += 1
|
|
126
|
+
# All changes saved atomically
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Pipeline Operations
|
|
130
|
+
Batch multiple operations for performance:
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
async with user.pipeline() as pipelined_user:
|
|
134
|
+
await pipelined_user.tags.aappend("redis")
|
|
135
|
+
await pipelined_user.metadata.aupdate(level="senior")
|
|
136
|
+
# Executed as single atomic transaction
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Type Support
|
|
140
|
+
|
|
141
|
+
Rapyer supports all Python types with automatic serialization:
|
|
142
|
+
|
|
143
|
+
- **Native types** (`str`, `int`, `List`, `Dict`) - Optimized Redis operations
|
|
144
|
+
- **Complex types** (`dataclass`, `Enum`, `Union`) - Automatic pickle serialization
|
|
145
|
+
- **Nested models** - Full Redis functionality preserved
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
from dataclasses import dataclass
|
|
149
|
+
from enum import Enum
|
|
150
|
+
|
|
151
|
+
@dataclass
|
|
152
|
+
class Config:
|
|
153
|
+
debug: bool = False
|
|
154
|
+
|
|
155
|
+
class User(AtomicRedisModel):
|
|
156
|
+
name: str = "default"
|
|
157
|
+
scores: List[int] = []
|
|
158
|
+
config: Config = Config() # Auto-serialized
|
|
159
|
+
|
|
160
|
+
# All types work identically
|
|
161
|
+
user = User()
|
|
162
|
+
await user.config.set(Config(debug=True)) # Automatic serialization
|
|
163
|
+
await user.scores.aappend(95) # Native Redis operation
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Why Rapyer?
|
|
167
|
+
|
|
168
|
+
### Race Condition Prevention
|
|
169
|
+
Traditional Redis operations can lead to data inconsistency in concurrent environments. Rapyer solves this with atomic operations and lock management.
|
|
170
|
+
|
|
171
|
+
### Developer Experience
|
|
172
|
+
- **Type Safety**: Full Pydantic v2 validation
|
|
173
|
+
- **Async/Await**: Native asyncio support
|
|
174
|
+
- **Intuitive API**: Pythonic Redis operations
|
|
175
|
+
|
|
176
|
+
### Performance
|
|
177
|
+
- **Pipeline Operations**: Batch multiple operations
|
|
178
|
+
- **Native Type Optimization**: Efficient Redis storage
|
|
179
|
+
- **Connection Pooling**: Built-in Redis connection management
|
|
180
|
+
|
|
181
|
+
## Learn More
|
|
182
|
+
|
|
183
|
+
- 📖 **[Documentation](https://yedidyakfir.github.io/rapyer/)** - Complete guide and API reference
|
|
184
|
+
- 🚀 **[Examples](https://yedidyakfir.github.io/rapyer/examples/)** - Real-world usage patterns
|
|
185
|
+
- ⚡ **[Advanced Features](https://yedidyakfir.github.io/rapyer/advanced/)** - Locks, pipelines, and nested models
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Contributing
|
|
190
|
+
|
|
191
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
MIT License
|
rapyer-0.0.1/README.md
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="icon.png" alt="Rapyer Logo" width="120">
|
|
3
|
+
|
|
4
|
+
# Rapyer
|
|
5
|
+
|
|
6
|
+
**Redis Atomic Pydantic Engine Reactor**
|
|
7
|
+
|
|
8
|
+
*An async Redis ORM that provides atomic operations for complex data models*
|
|
9
|
+
|
|
10
|
+
[](https://www.python.org/downloads/)
|
|
11
|
+
[](https://opensource.org/licenses/MIT)
|
|
12
|
+
[](https://redis.io/)
|
|
13
|
+
|
|
14
|
+
📚 **[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/)
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## What is Rapyer?
|
|
20
|
+
|
|
21
|
+
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.
|
|
22
|
+
|
|
23
|
+
### Key Features
|
|
24
|
+
|
|
25
|
+
🚀 **Atomic Operations** - Built-in atomic updates for complex Redis data structures
|
|
26
|
+
⚡ **Async/Await** - Full asyncio support for high-performance applications
|
|
27
|
+
🔒 **Type Safety** - Complete type validation using Pydantic v2
|
|
28
|
+
🌐 **Universal Types** - Native optimization for primitives, automatic serialization for complex types
|
|
29
|
+
🔄 **Race Condition Safe** - Lock context managers and pipeline operations
|
|
30
|
+
📦 **Redis JSON** - Efficient storage using Redis JSON with support for nested structures
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install rapyer
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Requirements:**
|
|
39
|
+
- Python 3.10+
|
|
40
|
+
- Redis server with JSON module
|
|
41
|
+
- Pydantic v2
|
|
42
|
+
|
|
43
|
+
## Quick Start
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
import asyncio
|
|
47
|
+
from rapyer.base import AtomicRedisModel
|
|
48
|
+
from typing import List, Dict
|
|
49
|
+
|
|
50
|
+
class User(AtomicRedisModel):
|
|
51
|
+
name: str
|
|
52
|
+
age: int
|
|
53
|
+
tags: List[str] = []
|
|
54
|
+
metadata: Dict[str, str] = {}
|
|
55
|
+
|
|
56
|
+
async def main():
|
|
57
|
+
# Create and save a user
|
|
58
|
+
user = User(name="John", age=30)
|
|
59
|
+
await user.save()
|
|
60
|
+
|
|
61
|
+
# Atomic operations that prevent race conditions
|
|
62
|
+
await user.tags.aappend("python")
|
|
63
|
+
await user.tags.aextend(["redis", "pydantic"])
|
|
64
|
+
await user.metadata.aupdate(role="developer", level="senior")
|
|
65
|
+
|
|
66
|
+
# Load user from Redis
|
|
67
|
+
loaded_user = await User.get(user.key)
|
|
68
|
+
print(f"User: {loaded_user.name}, Tags: {loaded_user.tags}")
|
|
69
|
+
|
|
70
|
+
# Atomic operations with locks for complex updates
|
|
71
|
+
async with user.lock("update_profile") as locked_user:
|
|
72
|
+
locked_user.age += 1
|
|
73
|
+
await locked_user.tags.aappend("experienced")
|
|
74
|
+
# Changes saved atomically when context exits
|
|
75
|
+
|
|
76
|
+
if __name__ == "__main__":
|
|
77
|
+
asyncio.run(main())
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Core Concepts
|
|
81
|
+
|
|
82
|
+
### Atomic Operations
|
|
83
|
+
Rapyer ensures data consistency with built-in atomic operations:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
# These operations are atomic and race-condition safe
|
|
87
|
+
await user.tags.aappend("python") # Add to list
|
|
88
|
+
await user.metadata.aupdate(role="dev") # Update dict
|
|
89
|
+
await user.score.set(100) # Set value
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Lock Context Manager
|
|
93
|
+
For complex multi-field updates:
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
async with user.lock("transaction") as locked_user:
|
|
97
|
+
locked_user.balance -= 50
|
|
98
|
+
locked_user.transaction_count += 1
|
|
99
|
+
# All changes saved atomically
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Pipeline Operations
|
|
103
|
+
Batch multiple operations for performance:
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
async with user.pipeline() as pipelined_user:
|
|
107
|
+
await pipelined_user.tags.aappend("redis")
|
|
108
|
+
await pipelined_user.metadata.aupdate(level="senior")
|
|
109
|
+
# Executed as single atomic transaction
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Type Support
|
|
113
|
+
|
|
114
|
+
Rapyer supports all Python types with automatic serialization:
|
|
115
|
+
|
|
116
|
+
- **Native types** (`str`, `int`, `List`, `Dict`) - Optimized Redis operations
|
|
117
|
+
- **Complex types** (`dataclass`, `Enum`, `Union`) - Automatic pickle serialization
|
|
118
|
+
- **Nested models** - Full Redis functionality preserved
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
from dataclasses import dataclass
|
|
122
|
+
from enum import Enum
|
|
123
|
+
|
|
124
|
+
@dataclass
|
|
125
|
+
class Config:
|
|
126
|
+
debug: bool = False
|
|
127
|
+
|
|
128
|
+
class User(AtomicRedisModel):
|
|
129
|
+
name: str = "default"
|
|
130
|
+
scores: List[int] = []
|
|
131
|
+
config: Config = Config() # Auto-serialized
|
|
132
|
+
|
|
133
|
+
# All types work identically
|
|
134
|
+
user = User()
|
|
135
|
+
await user.config.set(Config(debug=True)) # Automatic serialization
|
|
136
|
+
await user.scores.aappend(95) # Native Redis operation
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Why Rapyer?
|
|
140
|
+
|
|
141
|
+
### Race Condition Prevention
|
|
142
|
+
Traditional Redis operations can lead to data inconsistency in concurrent environments. Rapyer solves this with atomic operations and lock management.
|
|
143
|
+
|
|
144
|
+
### Developer Experience
|
|
145
|
+
- **Type Safety**: Full Pydantic v2 validation
|
|
146
|
+
- **Async/Await**: Native asyncio support
|
|
147
|
+
- **Intuitive API**: Pythonic Redis operations
|
|
148
|
+
|
|
149
|
+
### Performance
|
|
150
|
+
- **Pipeline Operations**: Batch multiple operations
|
|
151
|
+
- **Native Type Optimization**: Efficient Redis storage
|
|
152
|
+
- **Connection Pooling**: Built-in Redis connection management
|
|
153
|
+
|
|
154
|
+
## Learn More
|
|
155
|
+
|
|
156
|
+
- 📖 **[Documentation](https://yedidyakfir.github.io/rapyer/)** - Complete guide and API reference
|
|
157
|
+
- 🚀 **[Examples](https://yedidyakfir.github.io/rapyer/examples/)** - Real-world usage patterns
|
|
158
|
+
- ⚡ **[Advanced Features](https://yedidyakfir.github.io/rapyer/advanced/)** - Locks, pipelines, and nested models
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Contributing
|
|
163
|
+
|
|
164
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
165
|
+
|
|
166
|
+
## License
|
|
167
|
+
|
|
168
|
+
MIT License
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["poetry-core"]
|
|
3
|
+
build-backend = "poetry.core.masonry.api"
|
|
4
|
+
|
|
5
|
+
[tool.poetry]
|
|
6
|
+
name = "rapyer"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
description = "Pydantic models with Redis as the backend"
|
|
9
|
+
authors = ["YedidyaHKfir <your.email@example.com>"]
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
homepage = "https://github.com/YedidyaHKfir/rapyer"
|
|
13
|
+
repository = "https://github.com/YedidyaHKfir/rapyer"
|
|
14
|
+
documentation = "https://github.com/YedidyaHKfir/rapyer"
|
|
15
|
+
packages = [{include = "rapyer"}]
|
|
16
|
+
keywords = ["redis", "pydantic", "orm", "database", "async"]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 3 - Alpha",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Topic :: Database",
|
|
25
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[tool.poetry.dependencies]
|
|
29
|
+
python = ">=3.10,<4.0"
|
|
30
|
+
redis = { version = ">=6.4.0", extras = ["async"] }
|
|
31
|
+
pydantic = ">=2.11.9"
|
|
32
|
+
|
|
33
|
+
[tool.poetry.group.dev.dependencies]
|
|
34
|
+
black = "^25.9.0"
|
|
35
|
+
|
|
36
|
+
[tool.poetry.group.tests.dependencies]
|
|
37
|
+
pytest = "^8.4.2"
|
|
38
|
+
pytest-asyncio = "^0.25.0"
|
|
39
|
+
|