fix(cache): gracefully degrade Redis cache on connection failure - #100
Open
jack-o-brown wants to merge 1 commit into
Open
jack-o-brown wants to merge 1 commit into
jack-o-brown wants to merge 1 commit into
Conversation
When Redis is unreachable, RedisCache.get() and RedisCache.set() raise ConnectionError/TimeoutError which propagates to the request handler and crashes the request with a 500. The cache is an optimization, not a correctness requirement — a Redis outage should degrade to cache misses, not take down the router. Wrap both get() and set() in try/except so connection errors are caught: get() returns None (cache miss), set() is a no-op. The upstream call still succeeds and the next request retries the cache write.
There was a problem hiding this comment.
🐳 OrcaCode Review
✅ No findings — nothing to flag in this PR. Great work!
OrcaCode Review — Route Smarter. Ship Safer. Spend Less.
Engine-reported: 277 calls · 10.6M tokens · 98% cached
❤️ Share · Install OrcaCode Review
Free on GitHub — the review runs on your own OrcaRouter key. If it helped, a shout-out goes a long way.
Share: X · Reddit · LinkedIn
Follow: X · Discord · LinkedIn · OrcaRouter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Orca-Code-Review — push 1
✅ no blocking findings
When
REDIS_URLis set but Redis is unreachable,RedisCache.get()andRedisCache.set()raiseConnectionError/TimeoutErrorwhich propagates to the chat handler and crashes the request with a 500.The prompt cache is an optimization — a Redis outage should degrade to cache misses, not take down the router. The upstream provider call still succeeds; the next request retries the cache write.
Fix: wrap both
get()andset()intry/except Exceptionso connection errors are caught:get()returnsNone(cache miss) — caller hits upstream normallyset()is a no-op — next request retries the writeTests:
tests/unit/test_redis_cache_graceful.py— verifiesConnectionErrorandTimeoutErrorare caught on bothget()andset().