Joomla自定义模块的TTL缓存
问题描述:
请帮助我... 我无法为Joomla模块设置TTL缓存。这是 -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);
}
任何想法?谢谢你的建议。
答
$缓存= JFactory :: getCache( 'mod_jexchange_rates_cbr', ''); //任何唯一名称 $ cache-> setCaching(true); //强制高速缓存启用。如果缓存被禁用,那就是为什么你的数据实际上没有写入缓存。无论全局缓存设置如何,您都需要保留它。 $ cache-> setLifeTime(60); //分钟
你能否澄清“不工作”?你有错误吗?是实际执行的代码?你会得到意想不到的结果? *你期望得到什么结果? – HPierce
缓存文件在20秒后未更新:$ cache-> setLifeTime(20); – user320038