<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>爱周末 &#187; Smarty成员方法</title>
	<atom:link href="http://zhoumo123.cn/tag/smarty%e6%88%90%e5%91%98%e6%96%b9%e6%b3%95/feed" rel="self" type="application/rss+xml" />
	<link>http://zhoumo123.cn</link>
	<description>知识分享，共同进步。zhoumo123.cn</description>
	<lastBuildDate>Thu, 07 Nov 2019 05:53:49 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0.1</generator>
	<item>
		<title>isCached()检查模板是否已经缓存Smarty成员方法</title>
		<link>http://zhoumo123.cn/php/smarty/3197.html</link>
		<comments>http://zhoumo123.cn/php/smarty/3197.html#comments</comments>
		<pubDate>Mon, 17 Aug 2015 03:45:41 +0000</pubDate>
		<dc:creator><![CDATA[zhangc]]></dc:creator>
				<category><![CDATA[smarty]]></category>
		<category><![CDATA[Smarty成员方法]]></category>

		<guid isPermaLink="false">http://zhoumo123.cn/?p=3197</guid>
		<description><![CDATA[Name isCached() — 检查模板是否已经缓存 说明 bool isCached(string template,string cache_id,string compile_id); 此函数仅在 $caching设置为Smarty::CACHING_LIFETIME_CURRENT或Smarty::CACHING_LIFETIME_SAVED的时候启用。 参见 缓存。 当你需要使用多个缓存时，需要设置 $cache_id这个可选参数。 你可以传递第三个可选的参数 $compile id。 如果省略了该参数，那么会继续使用之前的 $compile_id，如果它有设置的话。 如果你不希 ...  <a href="http://zhoumo123.cn/php/smarty/3197.html">  阅读全文 </a>]]></description>
				<content:encoded><![CDATA[<p><strong>Name</strong><br />
isCached() — 检查模板是否已经缓存</p>
<p><strong>说明</strong></p>
<p><strong>bool isCached(string template,string cache_id,string compile_id);</strong></p>
<ul>
<li>此函数仅在 $caching设置为Smarty::CACHING_LIFETIME_CURRENT或Smarty::CACHING_LIFETIME_SAVED的时候启用。 参见 缓存。</li>
<li>当你需要使用多个缓存时，需要设置 $cache_id这个可选参数。</li>
<li>你可以传递第三个可选的参数 $compile id。 如果省略了该参数，那么会继续使用之前的 $compile_id，如果它有设置的话。</li>
<li>如果你不希望传递$cache_id但想传递 $compile_id参数，你可以传递一个NULL作为$cache_id.</li>
</ul>
<address><strong>技术说明</strong></address>
<address>如果isCached()返回 TRUE ，那么系统底层将已经载入了缓存的内容并存储到系统中。 接着执行的display() 或者 fetch() 将直接返回存储在系统中的缓存内容，而不会再从缓存文件内读取。 这个机制避免了在执行isCached()和 display()的时候重复两次读取缓存内容，导致系统开销。 这也意味着，在isCached() 返回TRUE后，调用的 clearCache() 或者其他缓存设置，将不会影响缓存的内容输出。</address>
<p><strong><em>Example 14.32. isCached()</em></strong></p>
<pre class="brush: php; title: ; notranslate">

&lt;?php
$smarty-&gt;setCaching(Smarty::CACHING_LIFETIME_CURRENT);

if(!$smarty-&gt;isCached('index.tpl')) {
// do database calls, assign vars here
}

$smarty-&gt;display('index.tpl');
?&gt;

</pre>
<p><strong>Example 14.33. isCached()用于多缓存的模板</strong></p>
<pre class="brush: php; title: ; notranslate">

&lt;?php
$smarty-&gt;setCaching(Smarty::CACHING_LIFETIME_CURRENT);

if(!$smarty-&gt;isCached('index.tpl', 'FrontPage')) {
  // do database calls, assign vars here
}

$smarty-&gt;display('index.tpl', 'FrontPage');
?&gt;

</pre>
]]></content:encoded>
			<wfw:commentRss>http://zhoumo123.cn/php/smarty/3197.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
