/** * Adds the commands needed for the count function. * * @param MultiExec $multi A MultiExec instance * @param string $subject A unique identifier, for example a session id or an IP * @param int $bucket Bucket * @param int $count Count */ private function addMultiExecCount(MultiExec $multi, $subject, $bucket, $count) { // Get the counts from the previous `$count` buckets $multi->hget($subject, $bucket); while ($count--) { $multi->hget($subject, (--$bucket + $this->bucketCount) % $this->bucketCount); } }