Writes a value to a file.
string $resource A cache key:
mixed $value A value to cache:
public function set($resource, $value) {
$path = $this
->getSourcePath($resource);
if (!is_dir($dir = dirname($path)) && false === @mkdir($dir, 0777, true)) {
// @codeCoverageIgnoreStart
throw new \RuntimeException('Unable to create directory ' . $dir);
// @codeCoverageIgnoreEnd
}
if (false === @file_put_contents($path, sprintf("<?php\n\n// {$resource}\nreturn %s;\n", var_export($value, true)))) {
// @codeCoverageIgnoreStart
throw new \RuntimeException('Unable to write file ' . $path);
// @codeCoverageIgnoreEnd
}
}