Skip to content

Feat/in memory cache#1

Open
xrvnd wants to merge 2 commits into
mainfrom
feat/in-memory-cache
Open

Feat/in memory cache#1
xrvnd wants to merge 2 commits into
mainfrom
feat/in-memory-cache

Conversation

@xrvnd

@xrvnd xrvnd commented May 19, 2026

Copy link
Copy Markdown
Owner

Summary

refactor: unify board cache using node-cache with (date+boardSize) key

  • Replaced two manual Maps (cachedBoardsByKey + cachedBoardsById) with setTimeout eviction with a node-cache instance
  • Unified all board access through a single cache key: date:boardSize changed from the puzzleId lookup path entirely
  • Updated all callers to pass (date + boardSize) instead of puzzleId, including API routes and client-side game actions.
  • Cache TTL is set to seconds until UTC midnight (end of day), after which node-cache evicts the entry automatically

Test

I manually verified using temporary console.log("CACHE HIT") / console.log("CACHE MISS") logs:

  • first request results in CACHE MISS + DB fetch
  • subsequent hint/check requests result in CACHE HIT without additional DB queries

Closes coder-zs-cse#11

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.

Add a memory cache to avoid repeated access to Current Board

1 participant