Skip to content

feat(backend): make memory cache sweep interval configurable and clearable (#643)#728

Merged
ogazboiz merged 1 commit into
LabsCrypt:mainfrom
TheDEV111:issue-643-configurable-memory-cache-sweep
Jun 1, 2026
Merged

feat(backend): make memory cache sweep interval configurable and clearable (#643)#728
ogazboiz merged 1 commit into
LabsCrypt:mainfrom
TheDEV111:issue-643-configurable-memory-cache-sweep

Conversation

@TheDEV111
Copy link
Copy Markdown
Contributor

@TheDEV111 TheDEV111 commented Jun 1, 2026

closes #643.

Description

  • Replaced the hardcoded 60_000ms MemoryCache cleanup sweep interval in backend/src/lib/redis.ts with a configurable interval that reads from process.env.MEMORY_CACHE_SWEEP_MS (defaulting to 60_000ms).
  • Stored the timer handle at module scope and exposed stopMemoryCacheSweep() to clean it up and prevent active timer leaks.
  • Exposed startMemoryCacheSweep(intervalMs?: number) to allow manual control or testing of different interval values.
  • Called stopMemoryCacheSweep() inside disconnectRedis() for symmetry.
  • Documented MEMORY_CACHE_SWEEP_MS with its default value in backend/.env.example.
  • Created robust unit test coverage in backend/tests/redis.test.ts to test cache sweep behavior (start, stop, and custom intervals), using a teardown block to prevent state leakage.

…rable (LabsCrypt#643)

- Replace the hardcoded 60s sweep interval with a configurable interval reading process.env.MEMORY_CACHE_SWEEP_MS (defaulting to 60_000ms).
- Store the interval handle and export stopMemoryCacheSweep() to prevent leaking timers across Vitest runs.
- Call stopMemoryCacheSweep() in disconnectRedis() for symmetry.
- Document MEMORY_CACHE_SWEEP_MS in .env.example.
- Expose startMemoryCacheSweep() and stopMemoryCacheSweep() in unit tests to test configuration and cleanup.
Copy link
Copy Markdown
Contributor

@ogazboiz ogazboiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean — closes #643 (cache sweep interval now AUTH_CHALLENGE_SWEEP_INTERVAL_MS-style configurable + clearable in tests). all CI green. merging!

join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0

@ogazboiz ogazboiz merged commit ee2f659 into LabsCrypt:main Jun 1, 2026
9 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.

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

2 participants