Bird
0
0

You want to configure Django to use a database table named my_cache_table for caching. Which is the correct CACHES setting to achieve this?

hard📝 Application Q15 of 15
Django - Caching
You want to configure Django to use a database table named my_cache_table for caching. Which is the correct CACHES setting to achieve this?
A'default': {'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': 'my_cache_table'}
B'default': {'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache', 'LOCATION': 'my_cache_table'}
C'default': {'BACKEND': 'django.core.cache.backends.db.DatabaseCache', 'LOCATION': 'my_cache_table'}
D'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': 'my_cache_table'}
Step-by-Step Solution
Solution:
  1. Step 1: Identify the backend for database caching

    The backend for caching in a database table is DatabaseCache.
  2. Step 2: Set the LOCATION to the table name

    The LOCATION must be the name of the database table, here my_cache_table.
  3. Final Answer:

    'default': {'BACKEND': 'django.core.cache.backends.db.DatabaseCache', 'LOCATION': 'my_cache_table'} -> Option C
  4. Quick Check:

    DB cache backend + table name = correct config [OK]
Quick Trick: DatabaseCache backend uses table name as LOCATION [OK]
Common Mistakes:
MISTAKES
  • Using file or memory cache backend for DB caching
  • Setting LOCATION to a file path instead of table name
  • Confusing Memcached with DB cache

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes