feat: add optional Redis/Valkey replay-store backend - #3
Merged
Merged
Conversation
- Add `ioredis` dependency and `createRedisReplayStore` with `altcha:replay:` key prefix, `SET ... EX ... NX` for atomic single-use enforcement. - Parse optional `REDIS_URL` in config; fail fast on startup if set but unreachable (no silent fallback to in-memory). - Select store backend in api-app.ts based on config.redisUrl. - Add `valkey` service to compose.yaml under `profiles: [redis]` with resource limits. - Document `REDIS_URL` and `--profile redis` usage in README. - Add integration tests for Redis replay store and run them in CI via a Valkey service container. Refs: plan altcha-docker-redis-valkey-36b158.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds an optional Redis/Valkey-backed
ReplayStorethat the API can use instead of the in-memory LRU cache whenREDIS_URLis configured. The in-memory store remains the default.Changes
ioredisfor Redis/Valkey connectivity.src/replay-store.ts: AddedcreateRedisReplayStore(redisUrl, ttlSeconds)withaltcha:replay:key namespace and atomicSET ... EX ... NXfor single-use enforcement.src/config.ts/src/config.test.ts: Added optionalredisUrl?: stringparsed fromREDIS_URL; tests for presence/absence.src/api-app.ts: Chooses Redis or in-memory store at startup. IfREDIS_URLis set, performs an eager connection check to fail fast (no silent fallback).compose.yaml: Added optionalvalkeyservice underprofiles: [redis]with resource limits (cpus: 0.5,memory: 128M).REDIS_URLis passed to the server service..env.example: AddedREDIS_URL=with usage comment.README.md: DocumentedREDIS_URLin Configuration, added--profile redisusage, and updated the production warning.src/replay-store.integration.test.ts: Integration tests for the Redis replay store. Added a Valkey service container to the GitHub Actionstestjob so these run in CI.