Bird
0
0

You want to use Redis cache backend in Django but also want to fallback to LocMemCache if Redis is unavailable. Which approach is best?

hard📝 Application Q8 of 15
Django - Caching
You want to use Redis cache backend in Django but also want to fallback to LocMemCache if Redis is unavailable. Which approach is best?
AUse Memcached backend instead of Redis
BSet BACKEND to RedisCache and LOCATION to both Redis and LocMemCache
CWrite custom cache wrapper that tries Redis then LocMemCache
DConfigure multiple BACKEND entries in settings.py
Step-by-Step Solution
Solution:
  1. Step 1: Understand Django cache backend limitations

    Django does not support multiple BACKEND entries or automatic fallback in settings.
  2. Step 2: Identify fallback solution

    Writing a custom cache wrapper that tries Redis first and falls back to LocMemCache on failure is the best approach.
  3. Final Answer:

    Write custom cache wrapper that tries Redis then LocMemCache -> Option C
  4. Quick Check:

    Fallback requires custom wrapper code [OK]
Quick Trick: Fallback caching needs custom wrapper logic [OK]
Common Mistakes:
MISTAKES
  • Trying to list multiple BACKENDs in settings
  • Assuming LOCATION can hold multiple backends
  • Switching to Memcached without fallback

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes