mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-28 15:49:57 +09:00
#242 file cache를 PHP 파일로 변경.
This commit is contained in:
parent
b29cf1fb67
commit
06a9e9fdac
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)
|
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)
|
function put($key, $obj, $valid_time = 0)
|
||||||
{
|
{
|
||||||
$cache_file = $this->getCacheFileName($key);
|
$cache_file = $this->getCacheFileName($key);
|
||||||
$text = serialize($obj);
|
$content = array();
|
||||||
FileHandler::writeFile($cache_file, $text);
|
$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)
|
function get($key, $modified_time = 0)
|
||||||
{
|
{
|
||||||
$cache_file = $this->getCacheFileName($key);
|
$cache_file = FileHandler::exists($this->getCacheFileName($key));
|
||||||
$content = FileHandler::readFile($cache_file);
|
|
||||||
|
if($cache_file) $content = include($cache_file);
|
||||||
|
|
||||||
if(!$content)
|
if(!$content)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return unserialize($content);
|
return unserialize(base64_decode($content));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue