Skip to content

feat: add optional Redis/Valkey replay-store backend - #3

Merged
smeinecke merged 1 commit into
mainfrom
feat/add-valkey-support
Jun 18, 2026
Merged

smeinecke merged 1 commit into
mainfrom
feat/add-valkey-support

Conversation

@smeinecke

Copy link
Copy Markdown

Summary

This PR adds an optional Redis/Valkey-backed ReplayStore that the API can use instead of the in-memory LRU cache when REDIS_URL is configured. The in-memory store remains the default.

Changes

  • New dependency: ioredis for Redis/Valkey connectivity.
  • src/replay-store.ts: Added createRedisReplayStore(redisUrl, ttlSeconds) with altcha:replay: key namespace and atomic SET ... EX ... NX for single-use enforcement.
  • src/config.ts / src/config.test.ts: Added optional redisUrl?: string parsed from REDIS_URL; tests for presence/absence.
  • src/api-app.ts: Chooses Redis or in-memory store at startup. If REDIS_URL is set, performs an eager connection check to fail fast (no silent fallback).
  • compose.yaml: Added optional valkey service under profiles: [redis] with resource limits (cpus: 0.5, memory: 128M). REDIS_URL is passed to the server service.
  • .env.example: Added REDIS_URL= with usage comment.
  • README.md: Documented REDIS_URL in Configuration, added --profile redis usage, 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 Actions test job so these run in CI.

- 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
@smeinecke
smeinecke merged commit 1e5500b into main Jun 18, 2026
2 checks passed
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