-
Notifications
You must be signed in to change notification settings - Fork 21
chore: Make cache defaults configurable via runtime env #161
Open
Description
The exported constants DEFAULT_GITHUB_CACHE_TTL_SECONDS and DEFAULT_CACHE_NAMESPACE in lib/cache-store.ts are currently hardcoded. These should be configurable from the runtime environment with safe fallbacks so deployments can tune cache behavior without code changes.
Suggested env vars (already partially supported by the code):
REDIS_CACHE_TTL_SECONDSorCACHE_TTL_SECONDS(fallback default should remain 604800)REDIS_CACHE_NAMESPACEorCACHE_NAMESPACE(fallback default should remain "devimpact:v1")
Tasks
- Update
lib/cache-store.tsto derive the exported defaults from environment values at runtime rather than fixed literals, or export accessor functions that return the configured values. - Ensure the module still exposes usable defaults when env vars are missing or invalid (keep existing numeric default and namespace).
- Add parsing and validation (positive integer for TTL, non-empty string for namespace) and reasonable upper bounds for TTL.
- Update
.env.exampleandREADME.mddocumenting the env vars and their defaults. - Add unit tests for the parsing/validation logic and any new accessors.
Notes
- Prefer server/runtime env access (not client-side
NEXT_PUBLIC_*). - The existing helper
getCacheConfigFromEnvalready reads these env vars for runtime configuration; consider aligning exported defaults with that helper to avoid duplication.
Tip
🚀 Want to contribute?
Comment assign me to be automatically assigned to this issue via our GitHub Actions bot. Happy coding! ✨