What FIFO message queue redis need to pay attention?

Typically use a list to queue operation, so there is a little limited, the task of unification are FIFO, if you want to prioritize a task is not very good to deal with, which need to have a concept of priority queue, we can give priority to high-level tasks, implementation of the following ways:

1) implement single list: Queuing normal operation is left right out (lpush, rpop) in order to handle high priority tasks, in the face of high-level task, you can directly jump the queue, directly into the head of the queue (rpush), Thus, when the head of the queue (the right) from the acquisition task, is taken to the high-priority task (RPOP)

2) the use of two queues, a common queue, a senior queue, the queue into a different level for the task, getting the task is very simple, redis of BRPOP command values ​​from multiple queues in order, will follow BRPOP key given the order to view and pop elements in a first non-empty list to find tail, redis> BRPOP list1 list2 0

Guess you like

Origin www.cnblogs.com/wzjwffg/p/11335165.html