Posted in ECSHOP, 程序开发

ecshop缓存函数

ken 2009-11-22 Hit: 323
/**
* 读结果缓存文件
*
* @params  string  $cache_name
*
* @return  array   $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;
    }
}
/**
* 写结果缓存文件
*
* @params  string  $cache_name
* @params  string  $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);
}

随机日志

欢迎订阅: Google Reader | 鲜果 | 抓虾 | 九点 | QQ邮箱 | 有道 | 更多

评论暂缺

  • (Required)
  • (Required, will not be published)
连接页面 | Sitemap

友情链接

Design By CKSKY TEAM VERSION 5.0 服务器赞助商: 优智科技