请帮帮我... 我无法为Joomla模块设置TTL缓存。这是 -
$cache->setLifeTime(20);
我的代码:
$cache = & JFactory::getCache('my_custom_mod', '');
$cacheKey = (string)$urls->serialize();
if (!($data = $cache->get($cacheKey))){
foreach ($urls as $i => $url){
$data[$i] = file_get_contents($url);
}
$cache->setLifeTime(20);
$cache->store($data, $cacheKey);
}
有什么想法吗?谢谢你的建议。
答案 0 :(得分:0)
$ cache = JFactory :: getCache(' mod_jexchange_rates_cbr',''); //任何唯一的名字 $的cache> setCaching(真); //强制缓存启用。如果禁用了缓存,那么这就是您的数据实际上没有写入缓存的原因。无论全局缓存设置如何,都需要它持久化。 $的cache> setLifeTime(60); //分钟