Joomla 缓存 Jcache

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wanghao725/article/details/51981712

joomla 通过 Jcache缓存数据:

//调用Cache,参数'com_campaign'为缓存组,必须!
$cache =   JFactory::getCache('com_campaign','');
//设置:即使关闭全局缓存时,此缓存仍有效
$cache->setCaching(true);
//设置缓存时间,此处设置为 60s
$cache->setLifeTime(60);
//获取缓存
$name	=	$cache->get('userid_101');
if(!$name){
    $str   =   'my name is cache';
    //设置缓存
    $cache->store($str,'userid_101');
}
echo '<pre>';print_r($name);exit;
//移除缓存
$cache->remove('userid_101');

//获取全部缓存对象列表及简介
$cache->getAll();
//清除缓存组。第二个参数为:group|notgroup 默认为group。notgroup不知道是干什么的
$cache->clean('com_campaign','group');

参考地址:
https://api.joomla.org/cms-3/classes/JCache.html
https://docs.joomla.org/API15:JCache

猜你喜欢

转载自blog.csdn.net/wanghao725/article/details/51981712