Replace in-memory game session store with Valkey #20
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Game sessions (the mapping of questionId -> correctOptionId for active quizzes) are stored in an in-memory Map inside the API process. Sessions are lost on API restart. Multiplayer requires persistent, shared state.
What to do
ValkeyGameSessionStoreusing the existingGameSessionStoreinterface.Files to change
docker-compose.yml(production, on VPS at~/lila-app/) — add valkey service. Reference:valkey/valkey:9.1-alpine3.23.apps/api/src/gameSessionStore/ValkeyGameSessionStore.ts— new file implementingGameSessionStoreinterface.apps/api/src/gameSessionStore/index.ts— export Valkey implementation. Switch based on env var (e.g.SESSION_STORE=valkey)..env(production) — add Valkey connection URL.Interface reference
Acceptance criteria
Notes
The dev compose already has Valkey. The
GameSessionStoreinterface was designed for this swap — all methods are async even in the in-memory implementation.