<?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/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>sylvan &#187; cache</title>
	<atom:link href="http://www.sylvan-l.net/b/tag/cache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sylvan-l.net/b</link>
	<description>GTD、ユーザビリティ、iPhone、本、アート</description>
	<lastBuildDate>Sat, 04 Feb 2012 17:44:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.sylvan-l.net/b/tag/cache/feed/" />
		<item>
		<title>cakephp1.2でcacheを使う</title>
		<link>http://www.sylvan-l.net/b/2008/01/04/cakephp12%e3%81%a7cache%e3%82%92%e4%bd%bf%e3%81%8a%e3%81%86%e3%81%a8%e3%81%99%e3%82%8b%e3%81%a8/</link>
		<comments>http://www.sylvan-l.net/b/2008/01/04/cakephp12%e3%81%a7cache%e3%82%92%e4%bd%bf%e3%81%8a%e3%81%86%e3%81%a8%e3%81%99%e3%82%8b%e3%81%a8/#comments</comments>
		<pubDate>Sat, 05 Jan 2008 06:01:21 +0000</pubDate>
		<dc:creator>sylvan</dc:creator>
				<category><![CDATA[その他]]></category>
		<category><![CDATA[Web開発関連]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.sylvan-l.net/b/2008/01/04/cakephp12%e3%81%a7cache%e3%82%92%e4%bd%bf%e3%81%8a%e3%81%86%e3%81%a8%e3%81%99%e3%82%8b%e3%81%a8/</guid>
		<description><![CDATA[cakephp1.1の時と同じように（ちょっと違うけど）キャッシュの設定をする。 core.phpの設定 Cache.checkのコメントを削除 Configure::write('Cache.check', true); controllerの設定 プロパティに追加（※Cacheヘルパーを指定しないと動かない） var $helpers = array('Html', 'Cache'); アクションに追加（※trueだと動かない） $this-&#62;cacheAction = '+12 hours'; これでキャッシュが有効になる。 以下はCacheヘルパーを指定しないといけないということに気づくまでのメモ。 ソースを追ってみると、cake/libs/view/view.phpの665行目のisset($this-&#62;loaded['cache'])がfalseな為キャッシュが無効と判定されている。 if &#40;isset&#40;$this-&#62;loaded&#91;'cache'&#93;&#41; &#38;&#38; &#40;&#40;$this-&#62;cacheAction != false&#41;&#41; &#38;&#38; &#40;Configure::read&#40;'Cache.check'&#41; === true&#41;&#41; &#123; &#160; &#160; &#160; &#160; &#160; &#160; if &#40;is_a&#40;$this-&#62;loaded&#91;'cache'&#93;, 'CacheHelper'&#41;&#41; &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; $cache =&#38; $this-&#62;loaded&#91;'cache'&#93;; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>cakephp1.1の時と同じように（ちょっと違うけど）キャッシュの設定をする。</p>
<ol>
<li>core.phpの設定</li>
<p>Cache.checkのコメントを削除</p>
<pre><code>Configure::write('Cache.check', true);</code></pre>
<li>controllerの設定</li>
<p>プロパティに追加（※Cacheヘルパーを指定しないと動かない）</p>
<pre><code>var $helpers = array('Html', 'Cache');</code></pre>
<p>アクションに追加（※trueだと動かない）</p>
<pre><code>$this-&gt;cacheAction = '+12 hours';</code></pre>
</ol>
<p>これでキャッシュが有効になる。</p>
<p><span id="more-812"></span><br />
以下はCacheヘルパーを指定しないといけないということに気づくまでのメモ。</p>
<p>ソースを追ってみると、cake/libs/view/view.phpの665行目のisset($this-&gt;loaded['cache'])がfalseな為キャッシュが無効と判定されている。</p>
<div class="syntax_hilite">
<div id="php-2">
<div class="php"><span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://jp.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">loaded</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'cache'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">cacheAction</span> != <span style="color:#000000; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; <span style="color:#006600; font-weight:bold;">&#40;</span>Configure::<span style="color:#006600;">read</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Cache.check'</span><span style="color:#006600; font-weight:bold;">&#41;</span> === <span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://jp.php.net/is_a"><span style="color:#000066;">is_a</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">loaded</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'cache'</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#FF0000;">'CacheHelper'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$cache</span> =&amp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">loaded</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'cache'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$cached</span> === <span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$cache</span>-&gt;<span style="color:#006600;">view</span> = &amp;<span style="color:#0000FF;">$this</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$cache</span>-&gt;<span style="color:#006600;">base</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">base</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$cache</span>-&gt;<span style="color:#006600;">here</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">here</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$cache</span>-&gt;<span style="color:#006600;">helpers</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">helpers</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$cache</span>-&gt;<span style="color:#006600;">action</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">action</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$cache</span>-&gt;<span style="color:#006600;">controllerName</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">name</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$cache</span>-&gt;<span style="color:#006600;">layout</span>&nbsp; = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">layout</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$cache</span>-&gt;<span style="color:#006600;">cacheAction</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">cacheAction</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$cache</span>-&gt;<span style="color:#006600;">cache</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$___viewFn</span>, <span style="color:#0000FF;">$out</span>, <span style="color:#0000FF;">$cached</span><span style="color:#006600; font-weight:bold;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
<p></p>
<p>loaded['cache']って何？って調べると読み込まれているヘルパーのことだったので、ヘルパーにCacheを指定すると無事キャッシュが有効なりました。<br />
よかった、ぜったいバグだと思ってた。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sylvan-l.net/b/2008/01/04/cakephp12%e3%81%a7cache%e3%82%92%e4%bd%bf%e3%81%8a%e3%81%86%e3%81%a8%e3%81%99%e3%82%8b%e3%81%a8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.sylvan-l.net/b/2008/01/04/cakephp12%e3%81%a7cache%e3%82%92%e4%bd%bf%e3%81%8a%e3%81%86%e3%81%a8%e3%81%99%e3%82%8b%e3%81%a8/" />
	</item>
	</channel>
</rss>

