Difficulty: Intermediate
Type: Feature
Recommended labels (if available in this repo): enhancement, caching, sdk
Background
examples/redis-cache-adapter/src/index.ts demonstrates plugging Redis into the SDK's cache interface, but as an example it likely omits production-readiness concerns like connection retry and failure isolation.
Problem
Consumers copying the example as a starting point for production use would inherit a Redis adapter that can crash or hang the whole app if Redis becomes temporarily unavailable, since caching should be a performance optimization, not a hard dependency.
Expected Outcome
The Redis adapter example gracefully degrades to cache-miss behavior (falling through to the origin call) when Redis is unreachable, with automatic reconnection and no unhandled promise rejections.
Suggested Implementation
Wrap Redis client calls in try/catch that treats connection errors as cache misses rather than throwing. Add reconnect-with-backoff logic (or rely on the Redis client library's built-in reconnection if available) and add a circuit-breaker-style short-circuit so repeated failures don't add per-request latency while Redis is down.
Acceptance Criteria
- Redis being unreachable at startup does not crash the consuming app — cache adapter falls back to pass-through behavior
- Redis becoming unreachable mid-run degrades to cache-miss behavior without throwing
- Existing
examples/redis-cache-adapter/src/index.test.ts extended to cover the failure-fallback path
- README in
examples/redis-cache-adapter/ updated to describe the fallback behavior
pnpm test:run passes
Likely Affected Files/Directories
examples/redis-cache-adapter/src/index.ts
examples/redis-cache-adapter/src/index.test.ts
examples/redis-cache-adapter/README.md
Difficulty: Intermediate
Type: Feature
Recommended labels (if available in this repo):
enhancement,caching,sdkBackground
examples/redis-cache-adapter/src/index.tsdemonstrates plugging Redis into the SDK's cache interface, but as an example it likely omits production-readiness concerns like connection retry and failure isolation.Problem
Consumers copying the example as a starting point for production use would inherit a Redis adapter that can crash or hang the whole app if Redis becomes temporarily unavailable, since caching should be a performance optimization, not a hard dependency.
Expected Outcome
The Redis adapter example gracefully degrades to cache-miss behavior (falling through to the origin call) when Redis is unreachable, with automatic reconnection and no unhandled promise rejections.
Suggested Implementation
Wrap Redis client calls in try/catch that treats connection errors as cache misses rather than throwing. Add reconnect-with-backoff logic (or rely on the Redis client library's built-in reconnection if available) and add a circuit-breaker-style short-circuit so repeated failures don't add per-request latency while Redis is down.
Acceptance Criteria
examples/redis-cache-adapter/src/index.test.tsextended to cover the failure-fallback pathexamples/redis-cache-adapter/updated to describe the fallback behaviorpnpm test:runpassesLikely Affected Files/Directories
examples/redis-cache-adapter/src/index.tsexamples/redis-cache-adapter/src/index.test.tsexamples/redis-cache-adapter/README.md