ecshop缓存操作函数

2016-07-07 15:04 来源:www.chinab4c.com 作者:ecshop专家

今天在修改ecshop首页时,发现了两个函数,对购物网站的性能提升很大的哟
/**
* 读结果缓存文件
*
* @paramsstring$cache_name
*
* @returnarray$data
*/
function read_static_cache($cache_name)
{
if ((DEBUG_MODE & 2) == 2)
{
return false;
}
static $result = array();
if (!empty($result[$cache_name]))
{
return $result[$cache_name];
}
$cache_file_path = ROOT_PATH . '/temp/static_caches/' . $cache_name . '.php';
if (file_exists($cache_file_path))
{
include_once($cache_file_path);
$result[$cache_name] = $data;
return $result[$cache_name];
}
else
{
return false;
}
}
/**
* 写结果缓存文件
*
* @paramsstring$cache_name
* @paramsstring$caches
*
* @return
*/
function write_static_cache($cache_name, $caches)
{
if ((DEBUG_MODE & 2) == 2)
{
return false;
}
$cache_file_path = ROOT_PATH . '/temp/static_caches/' . $cache_name . '.php';
$content = "<?php\r\n";
$content .= "\$data = " . var_export($caches, true) . ";\r\n";
$content .= "?>";
file_put_contents($cache_file_path, $content, LOCK_EX);
}

回答:
是缓存函数