コード例 #1
0
ファイル: RateLimit.php プロジェクト: Pouix/SncRedisBundle
 /**
  * Adds the commands needed for the increment 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
  */
 private function addMultiExecIncrement(MultiExec $multi, $subject, $bucket)
 {
     // Increment the current bucket
     $multi->hincrby($subject, $bucket, 1);
     // Clear the buckets ahead
     $multi->hdel($subject, ($bucket + 1) % $this->bucketCount)->hdel($subject, ($bucket + 2) % $this->bucketCount);
     // Renew the key TTL
     $multi->expire($subject, $this->subjectExpiry);
 }