Skip to content

chore: Make cache defaults configurable via runtime env #161

@O2sa

Description

@O2sa

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_SECONDS or CACHE_TTL_SECONDS (fallback default should remain 604800)
  • REDIS_CACHE_NAMESPACE or CACHE_NAMESPACE (fallback default should remain "devimpact:v1")

Tasks

  • Update lib/cache-store.ts to 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.example and README.md documenting 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 getCacheConfigFromEnv already 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! ✨

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions