Complete the code to set a key with an expiration time in Redis.
SET mykey myvalue EX [1]The EX option sets the expiration time in seconds. Here, 60 means the key expires after 60 seconds.
Complete the command to check the memory usage of a key in Redis.
MEMORY [1] mykeyThe MEMORY USAGE command returns the number of bytes used by the key.
Fix the error in the command to delete all keys matching a pattern.
KEYS [1] | xargs [2]
The KEYS * command lists all keys using the wildcard pattern *. Pipe to xargs DEL to delete them. Warning: Avoid in production; use SCAN instead for large datasets.
Fill both blanks to create a Redis command that sets a key only if it does not exist and expires after 120 seconds.
SET mykey myvalue [1] [2] 120
NX means set the key only if it does not exist. EX sets the expiration time in seconds.
Fill all three blanks to create a Redis command that sets a counter key with expiration in milliseconds.
SET [1] 1 [2] [3]
mycounter is the key for the counter. PX sets expiration in milliseconds. 60000 means 60 seconds.