0
0
Redisquery~10 mins

Eviction policies (LRU, LFU, random) in Redis - 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 eviction policy to Least Recently Used (LRU) in Redis configuration.

Redis
CONFIG SET maxmemory-policy [1]
Drag options to blanks, or click blank then click option'
Anoeviction
Bvolatile-lfu
Callkeys-lru
Drandom
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'volatile-lfu' which is for Least Frequently Used but only on volatile keys.
Using 'noeviction' which disables eviction.
Selecting 'random' which evicts keys randomly.
2fill in blank
medium

Complete the code to set the eviction policy to Least Frequently Used (LFU) for volatile keys only.

Redis
CONFIG SET maxmemory-policy [1]
Drag options to blanks, or click blank then click option'
Avolatile-lru
Ballkeys-random
Callkeys-lfu
Dvolatile-lfu
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'allkeys-lfu' which applies LFU to all keys, not just volatile ones.
Selecting 'volatile-lru' which is LRU, not LFU.
Using 'allkeys-random' which evicts keys randomly.
3fill in blank
hard

Fix the error in the command to set a random eviction policy.

Redis
CONFIG SET maxmemory-policy [1]
Drag options to blanks, or click blank then click option'
Arandom
Ballkeys-random
Cvolatile-random
Drandom-eviction
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'random' alone which is not a valid policy name.
Choosing 'random-eviction' which is not recognized.
Selecting 'volatile-random' which only evicts volatile keys.
4fill in blank
hard

Fill both blanks to set the max memory to 100mb and eviction policy to allkeys-lfu.

Redis
CONFIG SET maxmemory [1]
CONFIG SET maxmemory-policy [2]
Drag options to blanks, or click blank then click option'
A100mb
Ballkeys-lfu
Cvolatile-lru
D50mb
Attempts:
3 left
💡 Hint
Common Mistakes
Using '50mb' instead of '100mb' for maxmemory.
Choosing 'volatile-lru' which is a different eviction policy.
5fill in blank
hard

Fill all three blanks to configure Redis to use 200mb max memory, volatile-lru eviction policy, and set a key expiration of 60 seconds.

Redis
CONFIG SET maxmemory [1]
CONFIG SET maxmemory-policy [2]
EXPIRE mykey [3]
Drag options to blanks, or click blank then click option'
Avolatile-lru
B60
C200mb
Dallkeys-random
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up eviction policies like choosing 'allkeys-random' instead of 'volatile-lru'.
Setting expiration time in wrong units.