You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

626 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

一、异步消息队列

list 可以作为异步队列使用用rpush和lpop右进左出或lpush和rpop(左进右出) !Snipaste_2023-02-23_10-00-41 20.png 当队列为空时如果一直pop会陷入pop死循环可以采用与Future.get原理相同的阻塞读方法 blpop/brpop 其中b代表blocking

二、优先级队列

使用zset实现优先级队列score作为优先级分数

三、延时队列

使用zset实现延迟队列将消息序列化成一个字符串作为zset的value消息的时间作为到期时间score然后用多个线程轮询zset获取到期的任务进行处理。