silverstripe-framework/Core/Manifest/ManifestCache_File_PHP.php
Damian Mooyman 8dd644d25d
API Namespace all classes
Namespace all templates
Move difflib and BBCodeParser2 to thirdparty
Remove deprecated API marked for removal in 4.0
2016-09-08 10:23:17 +12:00

30 lines
662 B
PHP

<?php
namespace SilverStripe\Core\Manifest;
/**
* Same as ManifestCache_File, but stores the data as valid PHP which gets included to load
* This is a bit faster if you have an opcode cache installed, but slower otherwise
*/
class ManifestCache_File_PHP extends ManifestCache_File
{
function load($key)
{
global $loaded_manifest;
$loaded_manifest = null;
$file = $this->folder . '/cache_' . $key;
if (file_exists($file)) {
include $file;
}
return $loaded_manifest;
}
function save($data, $key)
{
$file = $this->folder . '/cache_' . $key;
file_put_contents($file, '<?php $loaded_manifest = ' . var_export($data, true) . ';');
}
}