雷迪斯 : how to create multiple redis queue/message broker

标签 redis

Redis 是内存数据库和消息代理。

比如我们可以在redis中创建多个数据库,

所以,像聪明人一样,

如何在redis中创建多个(消息代理/消息队列)?

最佳答案

您可以通过拥有多个列表来创建多个队列:

Pattern: Reliable queue Redis is often used as a messaging server to implement processing of background jobs or other kinds of messaging tasks. A simple form of queue is often obtained pushing values into a list in the producer side, and waiting for this values in the consumer side using RPOP (using polling), or BRPOP if the client is better served by a blocking operation. However in this context the obtained queue is not reliable as messages can be lost, for example in the case there is a network problem or if the consumer crashes just after the message is received but it is still to process. RPOPLPUSH (or BRPOPLPUSH for the blocking variant) offers a way to avoid this problem: the consumer fetches the message and at the same time pushes it into a processing list. It will use the LREM command in order to remove the message from the processing list once the message has been processed. An additional client may monitor the processing list for items that remain there for too much time, and will push those timed out items into the queue again if needed.

关于:

how to create multiple (message broker/message queues) in redis?

每个列表都是一个不同的队列。你可以有多个发送者和接收者的地方。 关于经纪人:那就是 Redis。 它还支持 pub/sub .

Source

关于雷迪斯 : how to create multiple redis queue/message broker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37098149/

相关文章:

REDIS:EXPIRE是否有事件

azure - 工作人员使用 celery、redis 和rabbitMQ 发回结果有 2 分钟延迟

c# - Redis 插入哈希非常(!)慢?

django - 在pythonanywhere上托管一个使用redis的Django项目

azure - 如何让Redis在Azure上运行?

database - Redis级联复制

PHPRedis - 时间()不起作用

python - Python Celery 任务的状态

c# - 如何使用 C# 连接到 Redis 服务器?

php - 如何结合 REDIS 和 MySQL 进行批量插入以获得更好的性能(实时)