break;
} if (null ===
$lastDeliveredId) { return 0;
} // Iterate through the stream. See https://redis.io/commands/xrange/#iterating-a-stream.
$useExclusiveRangeInterval =
version_compare(phpversion('redis'
), '6.2.0', '>='
);
$total = 0;
while (true
) { if (!
$range =
$redis->
xRange($this->stream,
$lastDeliveredId, '+', 100
)) { return $total;
} $total += \
count($range);
if ($useExclusiveRangeInterval) { $lastDeliveredId =
preg_replace_callback('#\d+$#',
static fn (array
$matches) =>
(int) $matches[0
] + 1,
array_key_last($range));
} else { $lastDeliveredId = '('.
array_key_last($range);
} } }