Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Store.php

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\HttpCache

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal