当前位置:网站首页>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
边栏推荐
猜你喜欢
Break the limit of file locks and use storage power to help enterprises grow new momentum
软件测试和硬件测试的区别及概念
mysql的case when如何用
You can't accept 60% slump, there is no eligible for gain of 6000% in 2021-05-27
CVE-2020-27986 (Sonarqube sensitive information leak) vulnerability fix
How to solve 1045 cannot log in to mysql server
鲲鹏devkit & boostkit
The future of financial services will never stop, and the bull market will continue 2021-05-28
【Tensorflow】AttributeError: ‘_TfDeviceCaptureOp‘ object has no attribute ‘_set_device_from_string‘
The most complete ever!A collection of 47 common terms of "digital transformation", read it in seconds~
随机推荐
rust使用mysql插入数据
面试官:可以谈谈乐观锁和悲观锁吗
软件测试和硬件测试的区别及概念
如何解决1045无法登录mysql服务器
The future of financial services will never stop, and the bull market will continue 2021-05-28
Raft对比ZAB协议
OpenMMLab简介
WiFi Association & Omnipeek Packet Capture Analysis
智能指针-使用、避坑和实现
RowBounds[通俗易懂]
电脑死机,Word忘了保存怎么办?怎么恢复?(编辑器是WPS)
Image retrieval method based on deep learning!
The world's largest Apache open source foundation is how it works?
2022-08-02日报:2022年7月最热的10篇AI论文
ZABBIX配置邮件报警和微信报警
存储过程详解
RKMPP 在FFmpeg上实现硬编解码
C# using 使用方法
期货具体是如何开户的?
GTK:Gdk-CRITICAL **: IA__gdk_draw_pixbuf: assertion ‘GDK_IS_DRAWABLE (drawable)‘ failed