You are here

public function Redis_Lock_PhpRedis::lockReleaseAll in Redis 7.3

Release all locks for the given lock token identifier.

Parameters

string $lockId = NULL: (optional) If none given, remove all lock from the current page.

Overrides Redis_Lock_BackendInterface::lockReleaseAll

File

lib/Redis/Lock/PhpRedis.php, line 119

Class

Redis_Lock_PhpRedis
Predis lock backend implementation.

Code

public function lockReleaseAll($lock_id = NULL) {
  if (!isset($lock_id) && empty($this->_locks)) {
    return;
  }
  $client = $this
    ->getClient();
  $id = isset($lock_id) ? $lock_id : $this
    ->getLockId();

  // We can afford to deal with a slow algorithm here, this should not happen
  // on normal run because we should have removed manually all our locks.
  foreach (array_keys($this->_locks) as $name) {
    $key = $this
      ->getKey($name);
    $owner = $client
      ->get($key);
    if (empty($owner) || $owner == $id) {
      $client
        ->delete($key);
    }
  }
}