当前位置:网站首页>redis延时队列
redis延时队列
2022-08-02 14:01:00 【意大利面拌42号混凝土】
redis延时队列
介绍
我们平时习惯于使用Rabbitmq和Kafka作为消息队列中间件,来给应用程序之间增加异步消息传递功能。这两个中间件都是专业的消息队列中间件,特性之多超出了大多数人的理解能力。
使用过Rabbitmq的同学知道它使用起来有多复杂,发消息之前要创建Exchange,再创建Queue,还要将Queue和Exchange通过某种规则绑定起来,发消息的时候要指定routingkey,还要控制头部信息。消费者在消费消息之前也要进行上面一系列的繁琐过程。但是绝大 多数情况下,虽然我们的消息队列只有一组消费者,但还是需要经历上面这些繁琐的过程。
有了 Redis,它就可以让我们解脱出来,对于那些只有一组消费者的消息队列,使用 Redis 就可以非常轻松的搞定。Redis 的消息队列不是专业的消息队列,它没有非常多的高级特性, 没有 ack 保证,如果对消息的可靠性有着极致的追求,那么它就不适合使用。
异步消息队列
Redis 的 list(列表) 数据结构常用来作为异步消息队列使用,使用rpush/lpush操作入队列, 使用 lpop 和 rpop 来出队列。

127.0.0.1:6379> lpush notfily-queue apple banana pear
(integer) 3
127.0.0.1:6379> llen notfily-queue
(integer) 3
127.0.0.1:6379> lpop notfily-queue
"apple"
127.0.0.1:6379> llen notfily-queue
(integer) 2
127.0.0.1:6379> lpop notfily-queue
"pear"
127.0.0.1:6379> lpop notfily-queue
"banana"
127.0.0.1:6379> lpop notfily-queue
(nil)
127.0.0.1:6379> llen notfily-queue
(integer) 0
边栏推荐
猜你喜欢

网络安全第二次作业

tinymce 如何实现动态国际化

logback源码阅读(一)获取ILoggerFactory、Logger

mysql的case when如何用

Sentinel源码(三)slot解析

打破文件锁限制,以存储力量助力企业增长新动力

鲲鹏devkit & boostkit

此次519暴跌的几点感触 2021-05-21

About the development forecast of the market outlook?2021-05-23

The bad policy has no long-term impact on the market, and the bull market will continue 2021-05-19
随机推荐
mysql的case when如何用
RKMPP API安装使用总结
拯救流浪猫 | 「喵先锋」系列数字版权盲盒明日开抢
CVE-2020-27986(Sonarqube敏感信息泄漏) 漏洞修复
Interview | with questions to learn, Apache DolphinScheduler Wang Fuzheng
苏州大学:从 PostgreSQL 到 TDengine
What are the file encryption software?Keep your files safe
Sentinel源码(六)ParamFlowSlot热点参数限流
【Tensorflow】AttributeError: ‘_TfDeviceCaptureOp‘ object has no attribute ‘_set_device_from_string‘
Sentinel源码(一)SentinelResourceAspect
数据机构---第六章图---图的遍历---选择题
Object detection scene SSD-Mobilenetv1-FPN
deal!It's July 30th!
【Tensorflow】AttributeError: module ‘keras.backend‘ has no attribute ‘tf‘
【Tensorflow】AttributeError: module 'keras.backend' has no attribute 'tf'
线代:已知一个特征向量快速求另外两个与之正交的特征向量
打破文件锁限制,以存储力量助力企业增长新动力
els long block deformation conditions, boundary collision judgment
Audio processing: floating point data stream to PCM file
LayoutParams的详解