Skip to content

[Backend] redis.ts MemoryCache.cleanup hardcoded 60s interval should be configurable #643

@ogazboiz

Description

@ogazboiz

Join the discussion on Telegram

Why this matters

backend/src/lib/redis.ts line 84:

setInterval(() => cache.cleanup(), 60000);

A bare unconfigurable 60-second sweep. Also runs even in tests (no clearInterval) which can leak timers across Vitest runs. Two small problems:

  1. No env knob.
  2. The interval is never cleared (so it survives module unload / test teardown). The import is module-level so it leaks for the lifetime of the process.

Acceptance criteria

  • Make the interval read process.env.MEMORY_CACHE_SWEEP_MS with 60_000 default
  • Store the timer handle and expose a stopMemoryCacheSweep() function called from the test shutdown path (and from disconnectRedis for symmetry)
  • Document in .env.example

Files to touch

  • backend/src/lib/redis.ts (line 84)

Out of scope

  • Swapping the in-memory cache for Redis caching of the same keys

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasksgood first issueGood for newcomersrefactorRefactoring existing code

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions