PHPCMS快速建站系列之getcache()的用法

來源:互聯網
上載者:User

標籤:param   ase   instance   預設   reg   path   etc   class   index.php   

/** * 讀取緩衝,預設為檔案快取,不載入緩衝配置。 * @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>

 

PHPCMS快速建站系列之getcache()的用法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.