Skip to content

feat: add configurable cache backend (redis/memcache)#279

Open
CrazyTodd-one wants to merge 2 commits intoopenclimatefix:mainfrom
CrazyTodd-one:fix/cache-backend-config
Open

feat: add configurable cache backend (redis/memcache)#279
CrazyTodd-one wants to merge 2 commits intoopenclimatefix:mainfrom
CrazyTodd-one:fix/cache-backend-config

Conversation

@CrazyTodd-one
Copy link
Copy Markdown

Pull Request

Description

Add configurable cache backend to support Redis/Memcache in production (#259).

The API currently uses InMemoryBackend which doesn't share cache across workers and has no size bounds. This adds CACHE_BACKEND and CACHE_URL environment variables to switch between inmemory, redis, or memcache.

Changes:

  • main.py: match/case backend selection based on config
  • server.conf: added CACHE_BACKEND and CACHE_URL config options
  • pyproject.toml: added redis extra to fastapi-cache2

Defaults to inmemory — no breaking changes. Set CACHE_BACKEND=redis and CACHE_URL=redis://host:6379 to switch.

Fixes #259

How Has This Been Tested?

  • Unit tests pass (17/17)
  • Default inmemory path unchanged
  • Verified redis/memcache imports resolve with updated deps

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and corrected any misspellings

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.

Upgrade Cache

1 participant