protected function unlock()
{
$elapsed = microtime(true) - $this->acquired;
if ($elapsed >= $this->timeout) {
$message = sprintf("The code executed for %d seconds. But the timeout is %d seconds.", $elapsed, $this->timeout);
throw new LockReleaseException($message);
}
/*
* Worst case would still be one second before the key expires.
* This guarantees that we don't delete a wrong key.
*/
if (!$this->release($this->key)) {
throw new LockReleaseException("Failed to release the lock.");
}
}