Complete the code to set the cache backend to use the local memory cache.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.[1].LocMemCache',
'LOCATION': 'unique-snowflake',
}
}The correct backend for local memory caching in Django is locmem.
Complete the code to set the cache timeout to 300 seconds.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'unique-snowflake',
'TIMEOUT': [1],
}
}The TIMEOUT setting defines how many seconds the cache will keep data. 300 seconds means 5 minutes.
Fix the error in the cache backend path to use Memcached.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.[1].MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}The correct backend path for Memcached is memcached.
Fill both blanks to configure Redis cache backend with a specific location and timeout.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.[1].RedisCache',
'LOCATION': '[2]',
'TIMEOUT': 500,
}
}Redis backend uses 'redis' and the location is usually the Redis server address like '127.0.0.1:6379'.
Fill all three blanks to create a file-based cache configuration with a directory and no timeout.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.[1].FileBasedCache',
'LOCATION': '[2]',
'TIMEOUT': [3],
}
}File-based cache backend is 'filebased', location is a directory path, and 'None' means cache never expires.