joomla는 Jcache를 통해 데이터를 캐시합니다:
<code><span>//调用Cache,参数'com_campaign'为缓存组,必须!</span><span>$cache</span><span>=</span> JFactory<span>::getCache</span>(<span>'com_campaign'</span>,<span>''</span>); <span>//设置:即使关闭全局缓存时,此缓存仍有效</span><span>$cache</span><span>-></span>setCaching(<span>true</span>); <span>//设置缓存时间,此处设置为 60s</span><span>$cache</span><span>-></span>setLifeTime(<span>60</span>); <span>//获取缓存</span><span>$name</span><span>=</span><span>$cache</span><span>-></span>get(<span>'userid_101'</span>); <span>if</span>(<span>!</span><span>$name</span>){ <span>$str</span><span>=</span><span>'my name is cache'</span>; <span>//设置缓存</span><span>$cache</span><span>-></span>store(<span>$str</span>,<span>'userid_101'</span>); } echo <span>'<pre class="brush:php;toolbar:false">'</span>;print_r(<span>$name</span>);exit; <span>//移除缓存</span><span>$cache</span><span>-></span>remove(<span>'userid_101'</span>); <span>//获取全部缓存对象列表及简介</span><span>$cache</span><span>-></span>getAll(); <span>//清除缓存组。第二个参数为:group|notgroup 默认为group。notgroup不知道是干什么的</span><span>$cache</span><span>-></span>clean(<span>'com_campaign'</span>,<span>'group'</span>); </code>
참조 주소:
https://api.joomla.org/cms-3/classes/JCache.html
https://docs.joomla.org/API15:JCache
위 내용은 Joomla 캐싱 Jcache를 소개했으며 PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되기를 바랍니다.