/** * @inheritdoc */ public function registerNonceAndTimestamp($nonce, $timestamp, ConsumerInterface $consumer) { if ($this->checkNonceAndTimestampUnicity($nonce, $timestamp, $consumer)) { $noncesRedisKey = $this->noncesRedisKey($consumer, $timestamp); $this->client->sadd($noncesRedisKey, [$nonce]); $this->client->expire($noncesRedisKey, $this->ttl); $timestampsKey = $this->timestampsKey($consumer); $this->client->zadd($timestampsKey, $timestamp, $timestamp); // While we're here, only keep the top 10 items. $sortedSet = $this->client->zrevrange($timestampsKey, 0, -1); if (is_array($sortedSet) && !empty($sortedSet)) { $lastTimestamp = $sortedSet[0]; $this->client->zremrangebyscore($timestampsKey, 0, $lastTimestamp - 1); } return true; } else { return false; } }
/** * {@inheritDoc} */ public function sadd($key, $member) { return $this->predis->sadd($key, $member); }