You are here

public function Redis_Lock_Backend_Predis::lockMayBeAvailable in Redis 7.2

Same name and namespace in other branches
  1. 7 lib/Redis/Lock/Backend/Predis.php \Redis_Lock_Backend_Predis::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/Predis.php, line 96

Class

Redis_Lock_Backend_Predis
Predis lock backend implementation.

Code

public function lockMayBeAvailable($name) {
  $client = Redis_Client::getClient();
  $key = $this
    ->getKey($name);
  $id = $this
    ->getLockId();
  $value = $client
    ->get($key);
  return empty($value) || $id == $value;
}