FastAPI Redis caching editorial sample, November 10, 2026.
Run tests with: python -m pytest test_app.py -q
21 local tests passed with a cache test double and in-process TestClient. One Starlette deprecation warning. No real Redis server, TTL timing, authentication handshake, Linux/container networking, load, concurrent invalidation or cloud validation.
app.py uses an in-memory fixture as the origin, not a database. There is no write endpoint, durable invalidation retry, request coalescing or circuit breaker. No speedup claim.
Real connection procedure requires REDIS_HOST, REDIS_PASSWORD_FILE, API_KEYS_FILE and an authorized private route. redis hostname only resolves on the matching Compose network. Keep Redis port 6379 unpublished. The client does not configure TLS.
Generate disposable API keys with prepare_api_keys.py; protect api_keys.json and do not commit it. Test fixtures are not credentials for a real service.
Requirements are direct tested pins, not a full dependency lock.
