<?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>Dominic.Xu&#039;s 博客 &#187; 分级目录</title>
	<atom:link href="http://xuplus.com/article/tag/%e5%88%86%e7%ba%a7%e7%9b%ae%e5%bd%95/feed" rel="self" type="application/rss+xml" />
	<link>http://xuplus.com</link>
	<description>Web 2.0 生活</description>
	<lastBuildDate>Wed, 24 Aug 2011 05:26:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>调整Smarty 模板引擎参数提高cache、templates_c目录读写性能</title>
		<link>http://xuplus.com/article/2007/04/a19.html</link>
		<comments>http://xuplus.com/article/2007/04/a19.html#comments</comments>
		<pubDate>Wed, 25 Apr 2007 09:10:09 +0000</pubDate>
		<dc:creator>Dominic</dc:creator>
				<category><![CDATA[Web应用]]></category>
		<category><![CDATA[XOOPS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Smarty]]></category>
		<category><![CDATA[分级目录]]></category>

		<guid isPermaLink="false">http://xuplus.com/?p=19</guid>
		<description><![CDATA[在用Xoops建立一个站点（只用Smarty引擎也一样）时，开启缓存之后cache和templates_c这两个目录用不了多长时间就充满了上千个文件乃至几十万个文件，操作一个包含数量巨大的文件的目录本来就很慢，这样会导致这两个目录的文件读取、删除、更新都很慢，本打算写一个cache handler来解决这个问题，在跟踪Smarty代码的时候发现Smarty已经解决了这个问题，那就是Smarty的use_sub_dirs属性，将该属性设置为true即可。PHP示例代码 [coolcode lang="php"]&#60;?php   require &#8216;../libs/Smarty.class.php&#8217;;   $smarty = new Smarty;   $smarty-&#62;use_sub_dirs = true;   $smarty-&#62;compile_check = true; $smarty-&#62;debugging = true; $smarty-&#62;caching = true; $smarty-&#62;cache_lifetime = 60; $smarty-&#62;assign(“Name”,”Fred Irving Johnathan Bradley Peppergill”); $smarty-&#62;assign(“FirstName”,array(“John”,”Mary”,”James”,”Henry”)); $smarty-&#62;assign(“LastName”,array(“Doe”,”Smith”,”Johnson”,”Case”)); $smarty-&#62;assign(“Class”,array(array(“A”,”B”,”C”,”D”), array(“E”, “F”, “G”, “H”),       array(“I”, “J”, “K”, “L”), array(“M”, “N”, “O”, “P”)));   $smarty-&#62;assign(“contacts”, array(array(“phone” =&#62; “1&#8243;, [...]]]></description>
			<content:encoded><![CDATA[<p><font size="3">在用Xoops建立一个站点（只用Smarty引擎也一样）时，开启缓存之后cache和templates_c这两个目录用不了多长时间就充满了上千个文件乃至几十万个文件，操作一个包含数量巨大的文件的目录本来就很慢，这样会导致这两个目录的文件读取、删除、更新都很慢，本打算写一个cache handler来解决这个问题，在跟踪Smarty代码的时候发现Smarty已经解决了这个问题，那就是Smarty的<font color="#ff0000">use_sub_dirs</font>属性，将该属性设置为true即可。PHP示例代码</font></p>
<p>[coolcode lang="<a href="http://xuplus.com/article/tag/php" class="st_tag internal_tag" rel="tag" title="标签 PHP 下的日志">php</a>"]&lt;?<a href="http://xuplus.com/article/tag/php" class="st_tag internal_tag" rel="tag" title="标签 PHP 下的日志">php</a><br />
 <br />
require &#8216;../libs/<a href="http://xuplus.com/article/tag/smarty" class="st_tag internal_tag" rel="tag" title="标签 Smarty 下的日志">Smarty</a>.class.php&#8217;;<br />
 <br />
$smarty = new Smarty;<br />
 <br />
$smarty-&gt;use_sub_dirs = true;<br />
 <br />
$smarty-&gt;compile_check = true;<br />
$smarty-&gt;debugging = true;<br />
$smarty-&gt;caching = true;<br />
$smarty-&gt;cache_lifetime = 60;<br />
$smarty-&gt;assign(“Name”,”Fred Irving Johnathan Bradley Peppergill”);<br />
$smarty-&gt;assign(“FirstName”,array(“John”,”Mary”,”James”,”Henry”));<br />
$smarty-&gt;assign(“LastName”,array(“Doe”,”Smith”,”Johnson”,”Case”));<br />
$smarty-&gt;assign(“Class”,array(array(“A”,”B”,”C”,”D”), array(“E”, “F”, “G”, “H”),<br />
      array(“I”, “J”, “K”, “L”), array(“M”, “N”, “O”, “P”)));<br />
 <br />
$smarty-&gt;assign(“contacts”, array(array(“phone” =&gt; “1&#8243;, “fax” =&gt; “2&#8243;, “cell” =&gt; “3&#8243;),<br />
      array(“phone” =&gt; “555-4444&#8243;, “fax” =&gt; “555-3333&#8243;, “cell” =&gt; “760-1234&#8243;)));<br />
 <br />
$smarty-&gt;assign(“option_values”, array(“NY”,”NE”,”KS”,”IA”,”OK”,”TX”));<br />
$smarty-&gt;assign(“option_output”, array(“New York”,”Nebraska”,”Kansas”,”Iowa”,”Oklahoma”,”Texas”));<br />
$smarty-&gt;assign(“option_selected”, “NE”);<br />
 <br />
$smarty-&gt;display(&#8216;index.tpl&#8217;);<br />
 <br />
?&gt;<br />
[/coolcode]</p>
<p><font size="3">对应Xoops中编辑Class\template.php文件第58行附近更改<font color="#ff0000">var $use_sub_dirs = false;</font>为<font color="#ff0000">var $use_sub_dirs = true;</font>即可。</font></p>

	标签： <a href="http://xuplus.com/article/tag/php" title="PHP" rel="tag">PHP</a>, <a href="http://xuplus.com/article/tag/smarty" title="Smarty" rel="tag">Smarty</a>, <a href="http://xuplus.com/article/tag/xoops" title="XOOPS" rel="tag">XOOPS</a>, <a href="http://xuplus.com/article/tag/%e5%88%86%e7%ba%a7%e7%9b%ae%e5%bd%95" title="分级目录" rel="tag">分级目录</a><br />
]]></content:encoded>
			<wfw:commentRss>http://xuplus.com/article/2007/04/a19.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

