public function Redis_Lock_Backend_PhpRedis::lockRelease in Redis 7
Same name and namespace in other branches
- 7.2 lib/Redis/Lock/Backend/PhpRedis.php \Redis_Lock_Backend_PhpRedis::lockRelease()
Release given lock.
Parameters
string $name:
Overrides Redis_Lock_Backend_Interface::lockRelease
File
- lib/
Redis/ Lock/ Backend/ PhpRedis.php, line 87
Class
- Redis_Lock_Backend_PhpRedis
- Predis lock backend implementation.
Code
public function lockRelease($name) {
$client = Redis_Client::getClient();
$key = 'lock:' . $name;
$keyOwn = $key . ':owner';
$id = $this
->getLockId();
unset($this->_locks[$name]);
$client
->watch($keyOwn);
// FIXME: Atomicity. Problem here is the check.
if ($client
->get($key . ':owner' == $id)) {
$client
->multi();
$client
->del(array(
$key,
$keyOwn,
));
$client
->exec();
}
else {
$client
->unwatch();
}
}