You are here

public function Redis_Lock_Backend_PhpRedis::lockMayBeAvailable in Redis 7

Same name and namespace in other branches
  1. 7.2 lib/Redis/Lock/Backend/PhpRedis.php \Redis_Lock_Backend_PhpRedis::lockMayBeAvailable()

Check if lock is available for acquire.

Parameters

string $name: Lock to acquire.

Return value

bool

Overrides Redis_Lock_Backend_Interface::lockMayBeAvailable

File

lib/Redis/Lock/Backend/PhpRedis.php, line 77

Class

Redis_Lock_Backend_PhpRedis
Predis lock backend implementation.

Code

public function lockMayBeAvailable($name) {
  $client = Redis_Client::getClient();
  $key = 'lock:' . $name;
  $id = $this
    ->getLockId();
  list($value, $owner) = $client
    ->mget(array(
    $key,
    $key . ':owner',
  ));
  return FALSE === $value || $id == $owner;
}