public function Redis_Lock_Backend_PhpRedis::lockReleaseAll in Redis 7
Same name and namespace in other branches
- 7.2 lib/Redis/Lock/Backend/PhpRedis.php \Redis_Lock_Backend_PhpRedis::lockReleaseAll()
Release all locks for the given lock token identifier.
Parameters
string $lockId = NULL: (optional) If none given, remove all lock from the current page.
Overrides Redis_Lock_Backend_Interface::lockReleaseAll
File
- lib/
Redis/ Lock/ Backend/ PhpRedis.php, line 108
Class
- Redis_Lock_Backend_PhpRedis
- Predis lock backend implementation.
Code
public function lockReleaseAll($lock_id = NULL) {
if (!isset($lock_id) && empty($locks)) {
return;
}
$client = Redis_Client::getClient();
$id = isset($lock_id) ? $lock_id : $this
->getLockId();
// We can afford to deal with a slow algorithm here, this should not happen
// on normal run because we should have removed manually all our locks.
foreach ($this->_locks as $name => $foo) {
$key = 'lock:' . $name;
// FIXME: Once again, this is not atomic, see lock_release() documentation.
if ($client
->get($key . ':owner' == $id)) {
$client
->del(array(
$key,
$key . ':owner',
));
}
}
}