0
0
Djangoframework~10 mins

Cache backends (memory, Redis, Memcached) 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 up the in-memory cache backend in Django settings.

Django
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.[1].Cache',
        'LOCATION': 'unique-snowflake',
    }
}
Drag options to blanks, or click blank then click option'
Amemcached
Bredis
Clocmem
Dfilebased
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'redis' or 'memcached' instead of 'locmem' for in-memory cache.
Confusing 'filebased' with in-memory cache.
2fill in blank
medium

Complete the code to configure Redis cache backend in Django settings.

Django
CACHES = {
    'default': {
        'BACKEND': 'django_redis.cache.[1]Cache',
        'LOCATION': 'redis://127.0.0.1:6379/1',
    }
}
Drag options to blanks, or click blank then click option'
Afilebased
Blocmem
Cmemcached
DRedis
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'locmem' or 'memcached' instead of 'Redis' for Redis cache.
Incorrect Redis URL format.
3fill in blank
hard

Fix the error in the Memcached cache backend configuration.

Django
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.[1].Cache',
        'LOCATION': '127.0.0.1:11211',
    }
}
Drag options to blanks, or click blank then click option'
Aredis
Bmemcached
Clocmem
Dfilebased
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'redis' or 'locmem' instead of 'memcached' for Memcached cache.
Wrong port or location format.
4fill in blank
hard

Fill both blanks to create a Redis cache backend with a custom timeout.

Django
CACHES = {
    'default': {
        'BACKEND': 'django_redis.cache.[1]Cache',
        'LOCATION': 'redis://127.0.0.1:6379/0',
        'TIMEOUT': [2],
    }
}
Drag options to blanks, or click blank then click option'
ARedis
B300
C600
Dmemcached
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong backend for Redis cache.
Setting timeout as string instead of integer.
5fill in blank
hard

Fill all three blanks to configure Memcached cache with a custom key prefix and timeout.

Django
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.[1].Cache',
        'LOCATION': '127.0.0.1:11211',
        'KEY_PREFIX': '[2]',
        'TIMEOUT': [3],
    }
}
Drag options to blanks, or click blank then click option'
Aredis
Bmemcached
Cmyapp
D600
Attempts:
3 left
💡 Hint
Common Mistakes
Using Redis backend for Memcached cache.
Not setting a key prefix or timeout properly.