Complete the code to set a key with a 10-second expiry using the EX option.
SET mykey myvalue [1] 10
The EX option sets the expiry time in seconds. Here, 10 means the key expires after 10 seconds.
Complete the code to set a key with a 5000-millisecond expiry using the PX option.
SET session_token abc123 [1] 5000
The PX option sets the expiry time in milliseconds. 5000 means the key expires after 5 seconds.
Fix the error in the command to set a key with a 20-second expiry using the correct expiry option.
SET user_id 42 [1] 20
The EX option is correct for setting expiry in seconds. PX would interpret 20 as milliseconds, which is too short.
Fill both blanks to set a key with a 3000-millisecond expiry and only if the key does not exist.
SET cache_key data [1] 3000 [2]
PX sets expiry in milliseconds. NX ensures the key is set only if it does not exist.
Fill all three blanks to set a key with a 15-second expiry, only if the key exists, and keep the existing TTL if no expiry is given.
SET config_value 100 [1] 15 [2] [3]
EX sets expiry in seconds. XX means set only if key exists. KEEPTTL keeps the existing TTL if no new expiry is specified.