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

Breadcrumb

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

function Store::save

Save data for the given key.

2 calls to Store::save()
Store::invalidate in vendor/symfony/http-kernel/HttpCache/Store.php
Invalidates all cache entries that match the request.
Store::write in vendor/symfony/http-kernel/HttpCache/Store.php
Writes a cache entry to the store for the given Request and Response.

File

vendor/symfony/http-kernel/HttpCache/Store.php, line 363

Class

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

Namespace

Symfony\Component\HttpKernel\HttpCache

Code

private function save(string $key, string $data, bool $overwrite = true) : bool {
    $path = $this->getPath($key);
    if (!$overwrite && file_exists($path)) {
        return true;
    }
    if (isset($this->locks[$key])) {
        $fp = $this->locks[$key];
        @ftruncate($fp, 0);
        @fseek($fp, 0);
        $len = @fwrite($fp, $data);
        if (\strlen($data) !== $len) {
            @ftruncate($fp, 0);
            return false;
        }
    }
    else {
        if (!is_dir(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) {
            return false;
        }
        $tmpFile = tempnam(\dirname($path), basename($path));
        if (false === ($fp = @fopen($tmpFile, 'w'))) {
            @unlink($tmpFile);
            return false;
        }
        @fwrite($fp, $data);
        @fclose($fp);
        if ($data != file_get_contents($tmpFile)) {
            @unlink($tmpFile);
            return false;
        }
        if (false === @rename($tmpFile, $path)) {
            @unlink($tmpFile);
            return false;
        }
    }
    @chmod($path, 0666 & ~umask());
    return true;
}

API Navigation

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