Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to set a key with a value in Redis.
Redis
SET mykey [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using EX 10 immediately after SET without a value.
Using DEL or GET instead of a value.
✗ Incorrect
The SET command requires the key and the value. Here, the value is "Hello".
2fill in blank
mediumComplete the code to set a key with a value and an expiration time of 30 seconds.
Redis
SET mykey "Hello" [1] 30
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using PX which sets expiration in milliseconds.
Using TTL or PTTL which are commands, not options here.
✗ Incorrect
The EX option sets the expiration time in seconds.
3fill in blank
hardFix the error in the command to set a key with expiration of 60 seconds.
Redis
SET mykey "World" [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using TTL or EXPIRE as options in SET command.
Using PX 60000 which is milliseconds, but the question expects seconds.
✗ Incorrect
The correct syntax to set expiration during SET is EX 60 for 60 seconds.
4fill in blank
hardFill both blanks to set a key with value and expiration in milliseconds.
Redis
SET mykey [1] [2] 15000
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using EX instead of PX for milliseconds.
Using "Permanent" as value when temporary data is needed.
✗ Incorrect
Use PX to set expiration in milliseconds and provide the value "Temporary".
5fill in blank
hardFill all three blanks to set a key with value and expiration, then check its TTL.
Redis
SET [1] [2] EX 20 TTL [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different key names in SET and TTL commands.
Not using quotes around the value string.
✗ Incorrect
Set key session_token with value "abc123" and expiration 20 seconds, then check TTL of session_token.