mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
#242 file cache를 PHP 파일로 변경.
This commit is contained in:
parent
1ca44bf2e3
commit
d4d43c1382
1 changed files with 11 additions and 6 deletions
17
classes/cache/CacheFile.class.php
vendored
17
classes/cache/CacheFile.class.php
vendored
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue