Bird
0
0

You want to configure Django to use Memcached but also want to ensure cache keys are namespaced per environment (dev, prod). How can you achieve this?

hard📝 Application Q9 of 15
Django - Caching
You want to configure Django to use Memcached but also want to ensure cache keys are namespaced per environment (dev, prod). How can you achieve this?
AUse Redis instead of Memcached for namespacing
BUse different BACKEND strings for each environment
CChange the LOCATION to include environment name
DSet the 'KEY_PREFIX' option in cache settings to environment name
Step-by-Step Solution
Solution:
  1. Step 1: Understand cache key namespacing

    Django cache supports a 'KEY_PREFIX' setting to add a prefix to all keys, isolating environments.
  2. Step 2: Apply KEY_PREFIX for environment separation

    Setting 'KEY_PREFIX' to 'dev' or 'prod' ensures keys do not collide across environments.
  3. Final Answer:

    Set the 'KEY_PREFIX' option in cache settings to environment name -> Option D
  4. Quick Check:

    KEY_PREFIX isolates cache keys per environment [OK]
Quick Trick: Use KEY_PREFIX to separate cache keys by environment [OK]
Common Mistakes:
MISTAKES
  • Changing BACKEND for environment separation
  • Modifying LOCATION for key namespacing
  • Thinking Redis is required for namespacing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes