You are here

protected function PhpFileCache::doSave in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/doctrine/cache/lib/Doctrine/Common/Cache/PhpFileCache.php \Doctrine\Common\Cache\PhpFileCache::doSave()

Puts data into the cache.

Parameters

string $id The cache id.:

string $data The cache entry/data.:

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

Return value

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

Overrides CacheProvider::doSave

File

vendor/doctrine/cache/lib/Doctrine/Common/Cache/PhpFileCache.php, line 75

Class

PhpFileCache
Php file cache driver.

Namespace

Doctrine\Common\Cache

Code

protected function doSave($id, $data, $lifeTime = 0) {
  if ($lifeTime > 0) {
    $lifeTime = time() + $lifeTime;
  }
  if (is_object($data) && !method_exists($data, '__set_state')) {
    throw new \InvalidArgumentException("Invalid argument given, PhpFileCache only allows objects that implement __set_state() " . "and fully support var_export(). You can use the FilesystemCache to save arbitrary object " . "graphs using serialize()/deserialize().");
  }
  $filename = $this
    ->getFilename($id);
  $value = array(
    'lifetime' => $lifeTime,
    'data' => $data,
  );
  $value = var_export($value, true);
  $code = sprintf('<?php return %s;', $value);
  return $this
    ->writeFile($filename, $code);
}