0
0
Redisquery~10 mins

Why caching patterns matter in Redis - Test Your Understanding

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

Complete the code to set a key-value pair in Redis.

Redis
redis_client.[1]('user:1', 'Alice')
Drag options to blanks, or click blank then click option'
Aset
Bget
Cdelete
Dexpire
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' instead of 'set' to store data.
Using 'expire' which sets a timeout, not the value.
2fill in blank
medium

Complete the code to retrieve a value by key from Redis.

Redis
value = redis_client.[1]('user:1')
Drag options to blanks, or click blank then click option'
Adel
Bset
Cexpire
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set' which writes data instead of reading.
Using 'del' which deletes keys.
3fill in blank
hard

Fix the error in the code to set a key with expiration time.

Redis
redis_client.set('session:123', 'active', [1]=3600)
Drag options to blanks, or click blank then click option'
Atimeout
Bex
Cexpire
Dttl
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'expire' as a parameter in set instead of 'ex'.
Using 'ttl' which is a command to check time left.
4fill in blank
hard

Fill both blanks to implement a cache check and set pattern.

Redis
value = redis_client.[1]('item:42')
if value is None:
    value = fetch_from_db('item:42')
    redis_client.[2]('item:42', value, ex=300)
Drag options to blanks, or click blank then click option'
Aget
Bset
Cdelete
Dexpire
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set' to read or 'get' to write.
Using 'expire' instead of 'set' to write data.
5fill in blank
hard

Fill all three blanks to implement a cache invalidation after update.

Redis
redis_client.[1]('product:99')
update_database('product:99', new_data)
redis_client.[2]('product:99', new_data)
redis_client.[3]('product:99', 600)
Drag options to blanks, or click blank then click option'
Adelete
Bset
Cexpire
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Not deleting old cache before updating.
Using 'get' instead of 'delete' to remove cache.