zoukankan      html  css  js  c++  java
  • PHPCMS快速建站系列之getcache()的用法

    /**
     * 读取缓存,默认为文件缓存,不加载缓存配置。
     * @param string $name 缓存名称
     * @param $filepath 数据路径(模块名称) caches/cache_$filepath/
     * @param string $config 配置名称
     */
    function getcache($name, $filepath='', $type='file', $config='') {
        if(!preg_match("/^[a-zA-Z0-9_-]+$/", $name)) return false;
        if($filepath!="" && !preg_match("/^[a-zA-Z0-9_-]+$/", $filepath)) return false;
        pc_base::load_sys_class('cache_factory','',0);
        if($config) {
            $cacheconfig = pc_base::load_config('cache');
            $cache = cache_factory::get_instance($cacheconfig)->get_cache($config);
        } else {
            $cache = cache_factory::get_instance()->get_cache($type);
        }
        return $cache->get($name, '', '', $filepath);
    }

    如上,getcache()函数。是调用缓存文件数据。

    应用:

    1.调用类别

    <ul>
    <?php $TYPE = getcache('type_content','commons');?> //当有多个站点时,缓存文件命名会发生变化,如:type_content_1,type_content_2,type_content_3  所以在调取时,需要做相应修改,
    //或者通用写法 <?php $TYPE = getcache('type_content_'.$siteid,'commons');?>
     {loop $TYPE $r} 

    <li><a href="index.php?m=content&c=type&catid={$catid}&typeid={$r[typeid]}">{$TYPE[$r[typeid]][name]}</a></li>
    {
    /loop}

    </ul>
  • 相关阅读:
    Struts2拦截器
    Struts2 数据封装与值栈
    Struts2的环境搭配
    自学spring AOP
    小白学Maven第二篇配置Ecilpse
    小白学Maven第一篇配置
    web项目jsp出现The superclass javax.servlet.http.HttpServlet was not found on the Java Build Path错误
    软件测试复习(二)
    软件测试复习(一)
    白盒测试概述
  • 原文地址:https://www.cnblogs.com/MY0101/p/6441065.html
Copyright © 2011-2022 走看看