protected function FilesystemCache::doSave

Puts data into the cache.

Parameters

string $id The cache id.:

string $data The cache entry/data.:

bool|int $lifeTime The lifetime. If != false, sets a specific lifetime for this: cache entry (null => infinite lifeTime).

Return value

boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise.

Overrides CacheProvider::doSave

File

drupal/core/vendor/doctrine/common/lib/Doctrine/Common/Cache/FilesystemCache.php, line 98

Class

FilesystemCache
Filesystem cache driver.

Namespace

Doctrine\Common\Cache

Code

protected function doSave($id, $data, $lifeTime = 0) {
  if ($lifeTime > 0) {
    $lifeTime = time() + $lifeTime;
  }
  $data = serialize($data);
  $filename = $this
    ->getFilename($id);
  $filepath = pathinfo($filename, PATHINFO_DIRNAME);
  if (!is_dir($filepath)) {
    mkdir($filepath, 0777, true);
  }
  return file_put_contents($filename, $lifeTime . PHP_EOL . $data);
}