Complete the code to add an item with a priority to a Redis sorted set.
ZADD tasks [1] "task1"
The ZADD command adds an item with a score (priority) to a sorted set. Here, 1 is the priority score.
Complete the code to get the highest priority item from the Redis sorted set.
ZRANGE tasks [1] [2] WITHSCORES
ZRANGE with start and stop as -1 returns the last element, which has the highest score (priority) in ascending order.
Fix the error in the code to remove the highest priority item from the sorted set.
ZREM tasks [1]ZREM removes a member by name. You must specify the member's name, not a command or index.
Fill both blanks to atomically pop the highest priority item from the sorted set.
ZPOPMAX [1] [2]
ZPOPMAX removes and returns the highest score members. The first argument is the key, the second is the count of items to pop.
Fill all three blanks to add a task with priority, then get and remove the highest priority task.
ZADD [1] [2] "task2" result = ZPOPMAX [3] 1
First, ZADD adds "task2" with priority 5 to the sorted set named "tasks". Then, ZPOPMAX removes and returns the highest priority task from the same set.