Idemptx

Latest version: v0.2.1

Safety actively analyzes 723217 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

0.2.1

---

✨ Added

- Support passing a `redis.Redis` or `redis.asyncio.Redis` instance directly into `RedisBackend` / `AsyncRedisBackend` for easier integration.

python
import redis
from idemptx.backend import RedisBackend

redis_backend = RedisBackend(redis.Redis(...))


- Improves developer ergonomics by reducing redundant Redis configuration logic in application code.

⚠️ Breaking Changes

- `RedisBackend` and `AsyncRedisBackend` constructors **no longer accept** `host`, `port`, and `db` parameters directly.
- You must now construct and pass a `redis.Redis` or `redis.asyncio.Redis` client explicitly.

**Before:**
python
RedisBackend(host='localhost', port=6379, db=0)


**After:**
python
redis_client = redis.Redis(host='localhost', port=6379, db=0)
RedisBackend(redis_client)

0.2.0

MIT License © 2025 [pypy-riley](https://github.com/pypy-riley)

0.1.2

> Elegant, lightweight **idempotency decorator** for FastAPI.
> Now supporting both **sync** and **async** Redis backends with conflict detection, locking, and automatic response replay.

---

✨ Highlights

- ✅ **Supports `Idempotency-Key` header** for safe re-submissions
- 🔒 **Distributed locking via Redis** to prevent double processing
- ⚡ **Sync & Async backend support**, auto-detected at runtime
- 🧠 **Request signature validation** (method, URL, headers, body)
- 🕒 **Configurable `wait_timeout`** behavior
- 🔁 **Automatic replay** of cached JSON responses
- 🧪 Fully tested for use in payment APIs, order creation, and more

---

🛠 Usage Example

python
from fastapi import FastAPI, Request
from idemptx import idempotent
from idemptx.backend.redis import RedisBackend

app = FastAPI()
backend = RedisBackend()

app.post("/orders")
idempotent(storage_backend=backend)
async def create_order(request: Request):
return {"status": "created"}


> ⚠️ Make sure to include `request: Request` in your endpoint parameters.

---

📦 Install

bash
pip install idemptx


---

📄 Metadata

- **Homepage**: [github.com/pypy-riley/idemptx](https://github.com/pypy-riley/idemptx)
- **License**: MIT
- **Python**: 3.9+
- **Dependencies**: `fastapi`, `redis>=4.2,<6.0`

Links

Releases

Has known vulnerabilities

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.