mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 02:31:40 +09:00
Fixed Apc Cache Handler
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7455 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
3d738e713a
commit
c7e0993d29
3 changed files with 17 additions and 12 deletions
17
classes/cache/CacheApc.class.php
vendored
17
classes/cache/CacheApc.class.php
vendored
|
|
@ -1,8 +1,17 @@
|
|||
<?php
|
||||
class CacheApc extends CacheBase {
|
||||
var $valid_time = 3600;
|
||||
/**
|
||||
* @class CacheApc
|
||||
* @author sol (sol@nhn.com)
|
||||
* @brief APC Handler
|
||||
* @version 0.1
|
||||
*
|
||||
**/
|
||||
|
||||
function getInstance(){
|
||||
|
||||
class CacheApc extends CacheBase {
|
||||
var $valid_time = 36000;
|
||||
|
||||
function getInstance($opt=null){
|
||||
if(!$GLOBALS['__CacheApc__']) {
|
||||
$GLOBALS['__CacheApc__'] = new CacheApc();
|
||||
}
|
||||
|
|
@ -13,7 +22,7 @@
|
|||
}
|
||||
|
||||
function isSupport(){
|
||||
return apc_store('xe', 'xe', 1);
|
||||
return function_exists('apc_add');
|
||||
}
|
||||
|
||||
function put($key, $buff, $valid_time = 0){
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@
|
|||
|
||||
$oCacheHandler = &CacheHandler::getInstance('template');
|
||||
if($oCacheHandler->isSupport()){
|
||||
$cache_key = 'template:'.$_SERVER['HTTP_HOST'] . $tpl_file;
|
||||
$cache_key = 'template:' . $tpl_file;
|
||||
$buff = $oCacheHandler->get($cache_key, filemtime(FileHandler::getRealPath($tpl_file)));
|
||||
if(!$buff){
|
||||
$buff = $this->_compileTplFile($tpl_file);
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ if($cache_support){
|
|||
}
|
||||
if(!is_array($list)) exit;
|
||||
|
||||
|
||||
// set content-type
|
||||
if($type == '.css'){
|
||||
$content_type = 'text/css';
|
||||
|
|
@ -63,6 +62,7 @@ if($type == '.css'){
|
|||
}
|
||||
|
||||
header("Content-Type: ".$content_type."; charset=UTF-8");
|
||||
|
||||
// return 304
|
||||
if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
|
||||
$modifiedSince = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
|
||||
|
|
@ -83,10 +83,7 @@ function useContentEncoding(){
|
|||
}
|
||||
|
||||
function getCacheKey($list){
|
||||
global $cache_support;
|
||||
$content_encoding = useContentEncoding();
|
||||
$key = 'optimized:' . join('',$list);
|
||||
$key .= $content_encoding?'gzip':'none';
|
||||
return $key;
|
||||
}
|
||||
|
||||
|
|
@ -109,12 +106,11 @@ function printFileList($list){
|
|||
$output .= "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if($content_encoding) $output = ob_gzhandler($output, 5);
|
||||
}
|
||||
|
||||
if($cache_support) $oCacheHandler->put($cache_key, $output);
|
||||
|
||||
if($content_encoding) $output = ob_gzhandler($output, 5);
|
||||
$size = strlen($output);
|
||||
|
||||
if($size > 0){
|
||||
|
|
@ -129,7 +125,7 @@ function printFileList($list){
|
|||
|
||||
if($content_encoding) header("Content-Encoding: gzip");
|
||||
|
||||
echo $output;
|
||||
echo($output);
|
||||
}
|
||||
|
||||
function write($file_name, $buff, $mode='w'){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue