silverstripe-framework/Core/Manifest/ManifestCache_File.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

38 lines
696 B
PHP

<?php
namespace SilverStripe\Core\Manifest;
/**
* Stores manifest data in files in TEMP_DIR dir on filesystem
*/
class ManifestCache_File implements ManifestCache
{
protected $folder = null;
function __construct($name)
{
$this->folder = TEMP_FOLDER . '/' . $name;
if (!is_dir($this->folder)) {
mkdir($this->folder);
}
}
function load($key)
{
$file = $this->folder . '/cache_' . $key;
return file_exists($file) ? unserialize(file_get_contents($file)) : null;
}
function save($data, $key)
{
$file = $this->folder . '/cache_' . $key;
file_put_contents($file, serialize($data));
}
function clear()
{
array_map('unlink', glob($this->folder . '/cache_*'));
}
}