Skip to content

feat: add RedisStore for production multi-instance deployments#94

Open
0xzoz wants to merge 1 commit intotempoxyz:mainfrom
P-U-C:feat/redis-store
Open

feat: add RedisStore for production multi-instance deployments#94
0xzoz wants to merge 1 commit intotempoxyz:mainfrom
P-U-C:feat/redis-store

Conversation

@0xzoz
Copy link

@0xzoz 0xzoz commented Mar 22, 2026

The existing MemoryStore works well for single-process deployments, but breaks in multi-instance environments — two server instances share no state, so a challenge issued by instance A can be replayed against instance B.

This PR adds RedisStore, a Redis-backed implementation of the Store protocol that solves this with atomic SET NX EX operations (no race conditions, no separate TTL call).

Usage:

from redis.asyncio import from_url
from mpp.stores.redis import RedisStore

store = RedisStore(await from_url("redis://localhost:6379"))

Includes: RedisStore + init.py, 7 tests, pympp[redis] optional dep.
Install with: pip install pympp[redis]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant