I am using Redis streams and need to block my clients until there are at least say X number of messages in the stream and return when it reaches that X count.. Is there any way to achieve this?
EG: XREADGROUP GROUP G1 C2 COUNT 10 BLOCK 0 STREAMS L >
until all 10 messages have arrived in the stream key
COUNT
specifies the maximum number of elements to return per stream, if there are any. If the streams are empty (and theBLOCK
option was used), the consumer blocks. Once there's a single incoming message, the blocking is released with that message. So no, you can't block untilCOUNT
messages are read. But you can probably group messages on the application level.See
XREAD
for more details.