#242 file cache를 PHP 파일로 변경.

This commit is contained in:
bnu 2014-01-05 02:30:17 +09:00
parent 1ca44bf2e3
commit d4d43c1382

View file

@ -49,7 +49,7 @@ class CacheFile extends CacheBase
*/
function getCacheFileName($key)
{
return $this->cache_dir . str_replace(':', '/', $key);
return $this->cache_dir . str_replace(':', '/', $key) . '.php';
}
/**
@ -73,8 +73,11 @@ class CacheFile extends CacheBase
function put($key, $obj, $valid_time = 0)
{
$cache_file = $this->getCacheFileName($key);
$text = serialize($obj);
FileHandler::writeFile($cache_file, $text);
$content = array();
$content[] = '<?php';
$content[] = 'if(!defined(\'__XE__\')) { exit(); }';
$content[] = 'return \'' . base64_encode(serialize($obj)) . '\';';
FileHandler::writeFile($cache_file, implode(PHP_EOL, $content));
}
/**
@ -104,14 +107,16 @@ class CacheFile extends CacheBase
*/
function get($key, $modified_time = 0)
{
$cache_file = $this->getCacheFileName($key);
$content = FileHandler::readFile($cache_file);
$cache_file = FileHandler::exists($this->getCacheFileName($key));
if($cache_file) $content = include($cache_file);
if(!$content)
{
return false;
}
return unserialize($content);
return unserialize(base64_decode($content));
}
/**