有没有类似于 Redis pub/sub 的订阅 Redis Streams 的方法?

Utk*_*rsh 7 architecture daemon system-design redis redis-streams

我正在构建一个数据管道,使用Maxwell Daemon实时读取 MySQL binlog ,Maxwell Daemon 将数据推送到 Redis 流。我构建了一个客户端,它使用 Redis 流中的数据并对其进行处理。目前,我正在使用无限循环轮询XREAD,睡眠时间为几毫秒,以消耗流中的数据,但我发现这是一个低效的解决方案。

I was searching for a way where I can somehow subscribe to the Redis stream and get notified whenever new entries are added to the stream and came across this GitHub issue where they talk about using the Redis pub/sub along with streams to achieve this functionality.

Is there a more efficient way of architecting this system?

Ita*_*ber 1

是的,使用BLOCK的论点XREAD,您将获得相同的“效率”。

文档: https: //redis.io/commands/xreadhttps://redis.io/topics/streams-intro#listening-for-new-items-with-xread