function Store::lock
Tries to lock the cache for a given Request, without blocking.
Return value
bool|string true if the lock is acquired, the path to the current lock otherwise
Overrides StoreInterface::lock
File
-
vendor/
symfony/ http-kernel/ HttpCache/ Store.php, line 72
Class
- Store
- Store implements all the logic for storing cache metadata (Request and Response headers).
Namespace
Symfony\Component\HttpKernel\HttpCacheCode
public function lock(Request $request) : bool|string {
$key = $this->getCacheKey($request);
if (!isset($this->locks[$key])) {
$path = $this->getPath($key);
if (!is_dir(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) {
return $path;
}
$h = fopen($path, 'c');
if (!flock($h, \LOCK_EX | \LOCK_NB)) {
fclose($h);
return $path;
}
$this->locks[$key] = $h;
}
return true;
}