public function Redis_Lock_Predis::lockRelease in Redis 7.3
Release given lock.
Parameters
string $name:
Overrides Redis_Lock_BackendInterface::lockRelease
File
- lib/
Redis/ Lock/ Predis.php, line 95
Class
- Redis_Lock_Predis
- Predis lock backend implementation.
Code
public function lockRelease($name) {
$client = $this
->getClient();
$key = $this
->getKey($name);
$id = $this
->getLockId();
unset($this->_locks[$name]);
// Ensure the lock deletion is an atomic transaction. If another thread
// manages to removes all lock, we can not alter it anymore else we will
// release the lock for the other thread and cause race conditions.
$client
->watch($key);
if ($client
->get($key) == $id) {
$client
->multi();
$client
->del(array(
$key,
));
$client
->exec();
}
else {
$client
->unwatch();
}
}