Complete the code to set up the in-memory cache backend in Django settings.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.[1].Cache',
'LOCATION': 'unique-snowflake',
}
}The in-memory cache backend in Django is called locmem. It stores cache data in local memory.
Complete the code to configure Redis cache backend in Django settings.
CACHES = {
'default': {
'BACKEND': 'django_redis.cache.[1]Cache',
'LOCATION': 'redis://127.0.0.1:6379/1',
}
}To use Redis as cache backend (requires django-redis package), Django uses the Redis backend path.
Fix the error in the Memcached cache backend configuration.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.[1].Cache',
'LOCATION': '127.0.0.1:11211',
}
}The Memcached backend in Django is specified as memcached. This fixes the backend path error.
Fill both blanks to create a Redis cache backend with a custom timeout.
CACHES = {
'default': {
'BACKEND': 'django_redis.cache.[1]Cache',
'LOCATION': 'redis://127.0.0.1:6379/0',
'TIMEOUT': [2],
}
}Use Redis as backend (requires django-redis) and set TIMEOUT to 300 seconds for cache expiration.
Fill all three blanks to configure Memcached cache with a custom key prefix and timeout.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.[1].Cache',
'LOCATION': '127.0.0.1:11211',
'KEY_PREFIX': '[2]',
'TIMEOUT': [3],
}
}Memcached backend is memcached. The key prefix helps separate cache keys, here set to myapp. Timeout is set to 600 seconds.