0
0
Djangoframework~10 mins

Cache framework configuration in Django - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the cache backend to use the local memory cache.

Django
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.[1].LocMemCache',
        'LOCATION': 'unique-snowflake',
    }
}
Drag options to blanks, or click blank then click option'
Amemcached
Blocmem
Cfilebased
Dredis
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'filebased' instead of 'locmem' for local memory cache.
Using 'memcached' without proper setup.
2fill in blank
medium

Complete the code to set the cache timeout to 300 seconds.

Django
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
        'LOCATION': 'unique-snowflake',
        'TIMEOUT': [1],
    }
}
Drag options to blanks, or click blank then click option'
A300
B0
C60
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Setting TIMEOUT to None disables expiration, not 300 seconds.
Using 0 means cache never expires, which is different.
3fill in blank
hard

Fix the error in the cache backend path to use Memcached.

Django
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.[1].MemcachedCache',
        'LOCATION': '127.0.0.1:11211',
    }
}
Drag options to blanks, or click blank then click option'
Afilebased
Bredis
Clocmem
Dmemcached
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'locmem' backend for Memcached configuration.
Using 'filebased' backend for Memcached.
4fill in blank
hard

Fill both blanks to configure Redis cache backend with a specific location and timeout.

Django
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.[1].RedisCache',
        'LOCATION': '[2]',
        'TIMEOUT': 500,
    }
}
Drag options to blanks, or click blank then click option'
Aredis
B127.0.0.1:6379
Cmemcached
Dlocmem
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'memcached' backend with Redis location.
Using 'locmem' backend for Redis.
5fill in blank
hard

Fill all three blanks to create a file-based cache configuration with a directory and no timeout.

Django
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.[1].FileBasedCache',
        'LOCATION': '[2]',
        'TIMEOUT': [3],
    }
}
Drag options to blanks, or click blank then click option'
Afilebased
B/var/tmp/django_cache
CNone
Dlocmem
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'locmem' backend for file-based cache.
Setting timeout to 0 instead of None for no expiration.