[英]TTL cache for the Joomla custom-module
Please, help me... I can not set the TTL cache for the Joomla module. 请帮帮我...我无法为Joomla模块设置TTL缓存。 This is - 这是 -
$cache->setLifeTime(20);
My code: 我的代码:
$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);
}
Any ideas? 有任何想法吗? Thanks for your advice. 谢谢你的建议。
$cache = JFactory::getCache('mod_jexchange_rates_cbr', ''); $ cache = JFactory :: getCache('mod_jexchange_rates_cbr',''); // Any unique name $cache->setCaching(true); //任何唯一的名称$ cache-> setCaching(true); // Force cache enable. //强制启用缓存。 If caching is disabled though, that would be why your data isn't actually writing to cache. 但是,如果禁用了缓存,这就是为什么您的数据实际上没有写入缓存的原因。 If you need it to persist regardless of global cache setting. 如果您需要它持久化,而不管全局缓存设置如何。 $cache->setLifeTime(60); $ cache-> setLifeTime(60); //Minutes //分钟
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.