Exemplo n.º 1
0
 /**
  * @test
  * @dataProvider getSecsToExpireProvider
  */
 public function getSecsToExpireShouldReturnDoesNotEpired($seconds, $minSecs, $maxSecs)
 {
     $keyValue = new KeyValue('irrelevantKey', 'irrelevantValue', 'irrelevantNamespace');
     $keyValue->setExpirationInSeconds($seconds);
     $secsToExpire = $keyValue->getSecsToExpire();
     $this->assertThat($minSecs, $this->lessThanOrEqual($secsToExpire));
     $this->assertThat($maxSecs, $this->greaterThanOrEqual($secsToExpire));
 }
 private function prepareExpiration($expiration)
 {
     if ($expiration != KeyValue::NO_EXPIRE) {
         $keyValue = new KeyValue('', '');
         $keyValue->setExpirationInSeconds($expiration);
         $expiration = $keyValue->getExpirationTimestamp();
     }
     return $expiration;
 }
 /**
  * {@inheritDoc}
  */
 public function get($key, $namespace = KeyValue::DEFAULT_NAMESPACE)
 {
     $value = $this->getValue($key, $namespace);
     $effectiveKey = $this->buildKey($key, $namespace);
     $expiration = $this->redisClient->ttl($effectiveKey);
     $keyValue = new KeyValue($key, $value, $namespace);
     if ($expiration !== -1) {
         $keyValue->setExpirationInSeconds($expiration);
     }
     return $keyValue;
 }