• 请不要在回答技术问题时复制粘贴 AI 生成的内容
crimeshaper
V2EX  ›  程序员

关于 redis stream 问题

  •  
  •   crimeshaper · Jan 21, 2020 · 2614 views
    This topic created in 2478 days ago, the information mentioned may be changed or developed.

    各位大佬,xread 和 xreadgroup block 阻塞后,一有新值就会立即返回,count 参数没用,就失效了。例如: XREAD BLOCK 5000 COUNT 100 STREAMS mystream $ 我想阻塞到凑够 count 数,比如 100 条后再返回,怎么解决,求各位不吝赐教啊。

    3 replies  •  2020-01-22 14:50:22 +08:00
    crimeshaper
    crimeshaper
    OP
    Jan 21, 2020
    1
    用了 block 就默认使用了 count 1,无解了。
    ql562482472
    ql562482472
    Jan 22, 2020
    2
    没有意义呀 你可以在业务代码中缓存一下 到 50 再返回
    stcheng
    stcheng
    Jan 22, 2020
    3
    redis 本身不支持这样使用,根据官方文档:
    “When the BLOCK command is passed, but there is data to return at least in one of the streams passed, the command is executed synchronously exactly like if the BLOCK option would be missing.”
    只要有 data,block 立刻就会被 resume。

    一方面考虑这个“达到 100 条再返回”的需求是否合理,另外一方面考虑如果有这个需求的话,同意在 wrapper 中加入缓存逻辑。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4765 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 03:54 · PVG 11:54 · LAX 19:54 · JFK 22:54
    ♥ Do have faith in what you're doing.