コード例 #1
0
 public function expireLock($ttlInSeconds)
 {
     if ($ttlInSeconds > 0 && $this->lockValue) {
         $success = $this->backend->expireIfKeyHasValue($this->lockKey, $this->lockValue, $ttlInSeconds);
         if (!$success) {
             $value = $this->backend->get($this->lockKey);
             $message = sprintf('Failed to expire key %s (%s / %s).', $this->lockKey, $this->lockValue, (string) $value);
             if ($value === false) {
                 Common::printDebug($message . ' It seems like the key already expired as it no longer exists.');
             } elseif (!empty($value) && $value == $this->lockValue) {
                 Common::printDebug($message . ' We still have the lock but for some reason it did not expire.');
             } elseif (!empty($value)) {
                 Common::printDebug($message . ' It seems to be locked by another queue.');
             } else {
                 Common::printDebug($message . ' Failed to expire key.');
             }
             return false;
         }
         return true;
     }
     return false;
 }
コード例 #2
0
 public function test_get_ShouldReturnTheSetValue_IfOneIsSet()
 {
     $this->redis->setIfNotExists($this->key, 'mytest', 60);
     $value = $this->redis->get($this->key);
     $this->assertEquals('mytest', $value);
 }
コード例 #3
0
 public function get($key)
 {
     $this->connectIfNeeded();
     return $this->redis->get($key);
 }