.env. Memory is fine while you’re developing; Redis is what you want
once more than one process is serving requests.
.env
CACHE_URL defaults to REDIS_URL. When CACHE_BACKEND is unset, REDIS_URL selects
redis. See automatic backends.
Caching function results
Results are keyed by the function’s arguments, so each distinct call gets its own entry.Caching route responses
Direct access
The
memory backend is per-process. Under gunicorn --workers 4 each worker keeps its
own cache, so hit rates look worse than they are and invalidation reaches one worker
only. Use redis whenever you run more than one process.