예제 #1
0
 /**
  * @param string $key
  * @throws LockException
  */
 public function increaseLockTimeout($key)
 {
     if (!isset($this->keys[$key])) {
         return FALSE;
     }
     if ($this->keys[$key] <= time()) {
         throw LockException::durabilityTimedOut();
     }
     $oldTimeout = $this->client->getSet($this->formatLock($key), $timeout = $this->calculateTimeout());
     if ((int) $oldTimeout !== (int) $this->keys[$key]) {
         throw LockException::invalidDuration();
     }
     $this->keys[$key] = $timeout;
     return TRUE;
 }
 /**
  * @param string $key
  * @throws LockException
  */
 public function increaseLockTimeout($key)
 {
     if (!isset($this->keys[$key])) {
         return FALSE;
     }
     if ($this->keys[$key] <= time()) {
         throw new LockException("Process ran too long. Increase lock duration, or extend lock regularly.");
     }
     $oldTimeout = $this->client->getSet($this->formatLock($key), $timeout = $this->calculateTimeout());
     if ((int) $oldTimeout !== (int) $this->keys[$key]) {
         throw new LockException("Some rude client have messed up the lock duration.");
     }
     $this->keys[$key] = $timeout;
     return TRUE;
 }