public function Redis_Lock_Backend_Predis::lockRelease in Redis 7
Same name and namespace in other branches
- 7.2 lib/Redis/Lock/Backend/Predis.php \Redis_Lock_Backend_Predis::lockRelease()
Release given lock.
Parameters
string $name:
Overrides Redis_Lock_Backend_Interface::lockRelease
File
- lib/
Redis/ Lock/ Backend/ Predis.php, line 99
Class
- Redis_Lock_Backend_Predis
- 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]);
// FIXME: AFAIK for acquire operation, the mutex is OK, but I'm not sure
// for this one, it'll need further brainstorming.
$client
->watch($keyOwn);
if ($client
->get($keyOwn == $id)) {
$client
->multi();
$client
->del(array(
$key,
$keyOwn,
));
$client
->exec();
}
else {
$client
->unwatch();
}
}