当前位置:网站首页>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
边栏推荐
猜你喜欢

The most complete ever!A collection of 47 common terms of "digital transformation", read it in seconds~

【Tensorflow】AttributeError: ‘_TfDeviceCaptureOp‘ object has no attribute ‘_set_device_from_string‘

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

微信小程序-最近动态滚动实现

【ONE·Data || Getting Started with Sorting】

RKMPP 在FFmpeg上实现硬编解码

Sentinel源码(三)slot解析

Raft协议图解,缺陷以及优化

CVE-2020-27986 (Sonarqube sensitive information leak) vulnerability fix

关于市场后市的发展预测? 2021-05-23
随机推荐
二分查找 && 树
Sentinel源码(五)FlowSlot以及限流控制器源码分析
网络安全第五次作业
世界上最大的开源基金会 Apache 是如何运作的?
Sentinel源码(四)(滑动窗口流量统计)
The bad policy has no long-term impact on the market, and the bull market will continue 2021-05-19
理解TCP长连接(Keepalive)
SQL函数 $TSQL_NEWID
软件测试和硬件测试的区别及概念
RKMPP 在FFmpeg上实现硬编解码
C# 编译错误:Compiler Error CS1044
C language improvement (3)
专访|带着问题去学习,Apache DolphinScheduler 王福政
第二讲 软件生命周期
WiFi Association & Omnipeek Packet Capture Analysis
shell脚本“画画”
关于C#使用DateTime数据的细节
Sentinel源码(二)入口方法分析
Differences and concepts between software testing and hardware testing
OpenMMLab简介