You are here

public function Store::lock in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/HttpCache/Store.php \Symfony\Component\HttpKernel\HttpCache\Store::lock()

Locks the cache for a given Request.

Parameters

Request $request A Request instance:

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 74

Class

Store
Store implements all the logic for storing cache metadata (Request and Response headers).

Namespace

Symfony\Component\HttpKernel\HttpCache

Code

public function lock(Request $request) {
  $path = $this
    ->getPath($this
    ->getCacheKey($request) . '.lck');
  if (!is_dir(dirname($path)) && false === @mkdir(dirname($path), 0777, true)) {
    return false;
  }
  $lock = @fopen($path, 'x');
  if (false !== $lock) {
    fclose($lock);
    $this->locks[] = $path;
    return true;
  }
  return !file_exists($path) ?: $path;
}