<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: symfony cache system: cache growing too large</title>
	<atom:link href="http://stereointeractive.com/blog/2009/04/10/symfony-cache-system-cache-growing-too-large/feed/" rel="self" type="application/rss+xml" />
	<link>http://stereointeractive.com/blog/2009/04/10/symfony-cache-system-cache-growing-too-large/</link>
	<description>Development Blog</description>
	<lastBuildDate>Thu, 17 Jun 2010 09:37:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Robin Corps</title>
		<link>http://stereointeractive.com/blog/2009/04/10/symfony-cache-system-cache-growing-too-large/comment-page-1/#comment-528</link>
		<dc:creator>Robin Corps</dc:creator>
		<pubDate>Thu, 18 Feb 2010 14:25:12 +0000</pubDate>
		<guid isPermaLink="false">http://stereointeractive.com/blog/?p=193#comment-528</guid>
		<description>In Symfony 1.2 (at least) you can do the following to clear cache cross application from within an action (eg. clear frontend cache from backend app):

$configuration =  ProjectConfiguration::getApplicationConfiguration(&#039;frontend&#039;, sfContext::getInstance()-&gt;getConfiguration()-&gt;getEnvironment(), false);
$context = sfContext::createInstance($configuration);
$cache_manager = $context-&gt;getViewCacheManager();
$cache_manager-&gt;remove(&#039;@sf_cache_partial?module=[your_module]&amp;action=[your_action]&amp;sf_cache_key=[your_id]&#039;);

This example would clear a given partial in the frontend app from the backend app.

Hope that helps someone!
Robin</description>
		<content:encoded><![CDATA[<p>In Symfony 1.2 (at least) you can do the following to clear cache cross application from within an action (eg. clear frontend cache from backend app):</p>
<p>$configuration =  ProjectConfiguration::getApplicationConfiguration(&#8216;frontend&#8217;, sfContext::getInstance()-&gt;getConfiguration()-&gt;getEnvironment(), false);<br />
$context = sfContext::createInstance($configuration);<br />
$cache_manager = $context-&gt;getViewCacheManager();<br />
$cache_manager-&gt;remove(&#8216;@sf_cache_partial?module=[your_module]&amp;action=[your_action]&amp;sf_cache_key=[your_id]&#8216;);</p>
<p>This example would clear a given partial in the frontend app from the backend app.</p>
<p>Hope that helps someone!<br />
Robin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nei Rauni Santos</title>
		<link>http://stereointeractive.com/blog/2009/04/10/symfony-cache-system-cache-growing-too-large/comment-page-1/#comment-466</link>
		<dc:creator>Nei Rauni Santos</dc:creator>
		<pubDate>Thu, 13 Aug 2009 20:58:50 +0000</pubDate>
		<guid isPermaLink="false">http://stereointeractive.com/blog/?p=193#comment-466</guid>
		<description>Hi, I&#039;m trying to show the cache datetime on my template. can you help me?

on my action I do it:

&lt;code&gt;
$cacheManager = $this-&gt;getContext()-&gt;getViewCacheManager();
    $component_uri = &quot;@sf_cache_partial?module=dashboard&amp;action=_translations&amp;sf_cache_key=40cd750bba9870f18aada2478b24840a&quot;;
    
    $this-&gt;lastModified = $cacheManager-&gt;getLastModified( $component_uri );
    $this-&gt;lifetime = $cacheManager-&gt;getLifetime( $component_uri );
&lt;/code&gt;

and on my template I did it:
&lt;code&gt;
 
 this cache was generated at , next update will be in  seconds
&lt;/code&gt;

I worked fine, but the variable sf_cache_key=40cd750bba9870f18aada2478b24840a&quot; is hardcoded, how can I get this key dinamicaly??

thank you,

Nei</description>
		<content:encoded><![CDATA[<p>Hi, I&#8217;m trying to show the cache datetime on my template. can you help me?</p>
<p>on my action I do it:</p>
<p><code><br />
$cacheManager = $this-&gt;getContext()-&gt;getViewCacheManager();<br />
    $component_uri = "@sf_cache_partial?module=dashboard&amp;action=_translations&amp;sf_cache_key=40cd750bba9870f18aada2478b24840a";</p>
<p>    $this-&gt;lastModified = $cacheManager-&gt;getLastModified( $component_uri );<br />
    $this-&gt;lifetime = $cacheManager-&gt;getLifetime( $component_uri );<br />
</code></p>
<p>and on my template I did it:<br />
<code></p>
<p> this cache was generated at , next update will be in  seconds<br />
</code></p>
<p>I worked fine, but the variable sf_cache_key=40cd750bba9870f18aada2478b24840a&#8221; is hardcoded, how can I get this key dinamicaly??</p>
<p>thank you,</p>
<p>Nei</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Meves</title>
		<link>http://stereointeractive.com/blog/2009/04/10/symfony-cache-system-cache-growing-too-large/comment-page-1/#comment-425</link>
		<dc:creator>Scott Meves</dc:creator>
		<pubDate>Sat, 06 Jun 2009 18:33:27 +0000</pubDate>
		<guid isPermaLink="false">http://stereointeractive.com/blog/?p=193#comment-425</guid>
		<description>You&#039;re right about the typo, thank you!

A cron job would work well for the cases where you end up with lots of old cache files sitting around; symfony won&#039;t delete them until they need them again and see they are too old. But, it doesn&#039;t fix the case where an object from your model is modified and you don&#039;t those old cached files lingering around between the time it was modified and the time the cron script runs. For example, if you had a blog post and you cached the blog/show?id=xx view, and then you made an edit to the blog post content, you&#039;d want to see your edits right away and not wait until your cache file reached the age limit. 

So, the core of the issue is this: You need some way to link modifications of your model objects to a list of cached files that are affected by the change. As long as you listen in to when the object is modified, you can move the actual list of which files are modified out of the model and into some other class or even listener so keep your MVC components clean.</description>
		<content:encoded><![CDATA[<p>You&#8217;re right about the typo, thank you!</p>
<p>A cron job would work well for the cases where you end up with lots of old cache files sitting around; symfony won&#8217;t delete them until they need them again and see they are too old. But, it doesn&#8217;t fix the case where an object from your model is modified and you don&#8217;t those old cached files lingering around between the time it was modified and the time the cron script runs. For example, if you had a blog post and you cached the blog/show?id=xx view, and then you made an edit to the blog post content, you&#8217;d want to see your edits right away and not wait until your cache file reached the age limit. </p>
<p>So, the core of the issue is this: You need some way to link modifications of your model objects to a list of cached files that are affected by the change. As long as you listen in to when the object is modified, you can move the actual list of which files are modified out of the model and into some other class or even listener so keep your MVC components clean.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lawrence Krubner</title>
		<link>http://stereointeractive.com/blog/2009/04/10/symfony-cache-system-cache-growing-too-large/comment-page-1/#comment-424</link>
		<dc:creator>Lawrence Krubner</dc:creator>
		<pubDate>Sat, 06 Jun 2009 18:12:50 +0000</pubDate>
		<guid isPermaLink="false">http://stereointeractive.com/blog/?p=193#comment-424</guid>
		<description>I am curious, wouldn&#039;t it be easier to write a cron that lives outside of Symfony (or maybe do this as a task) and which periodically sweeps through the cache and deletes any file that is older than a certain period? That would cut down on those files that arise simply because of some random search that someone did 4 months ago. Like David, above, I&#039;m uncomfortable having the model classes know about specific partials. That seems like a major violation of MVC principles. 

By the way, you write: 

&quot;&lt;i&gt;say this partial is in our app’s layout folder  and is called _headerNav.php.
&lt;?php include_partial(&#039;global/searchTop&#039;) ?&gt;&lt;/i&gt;&quot;

Is that a typo? Shouldn&#039;t it be &quot;headerNav&quot;?</description>
		<content:encoded><![CDATA[<p>I am curious, wouldn&#8217;t it be easier to write a cron that lives outside of Symfony (or maybe do this as a task) and which periodically sweeps through the cache and deletes any file that is older than a certain period? That would cut down on those files that arise simply because of some random search that someone did 4 months ago. Like David, above, I&#8217;m uncomfortable having the model classes know about specific partials. That seems like a major violation of MVC principles. </p>
<p>By the way, you write: </p>
<p>&#8220;<i>say this partial is in our app’s layout folder  and is called _headerNav.php.<br />
&lt;?php include_partial(&#8216;global/searchTop&#8217;) ?&gt;</i>&#8221;</p>
<p>Is that a typo? Shouldn&#8217;t it be &#8220;headerNav&#8221;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Colin</title>
		<link>http://stereointeractive.com/blog/2009/04/10/symfony-cache-system-cache-growing-too-large/comment-page-1/#comment-416</link>
		<dc:creator>Colin</dc:creator>
		<pubDate>Mon, 04 May 2009 18:02:20 +0000</pubDate>
		<guid isPermaLink="false">http://stereointeractive.com/blog/?p=193#comment-416</guid>
		<description>I couldn&#039;t help but notice nobody has mentioned the auto cleaning factor

http://trac.symfony-project.org/browser/branches/1.0/lib/cache/sfFileCache.class.php#L73

Could be that the only documentation of this setting is the source code itself :P

- CH</description>
		<content:encoded><![CDATA[<p>I couldn&#8217;t help but notice nobody has mentioned the auto cleaning factor</p>
<p><a href="http://trac.symfony-project.org/browser/branches/1.0/lib/cache/sfFileCache.class.php#L73" rel="nofollow">http://trac.symfony-project.org/browser/branches/1.0/lib/cache/sfFileCache.class.php#L73</a></p>
<p>Could be that the only documentation of this setting is the source code itself <img src='http://stereointeractive.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>- CH</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://stereointeractive.com/blog/2009/04/10/symfony-cache-system-cache-growing-too-large/comment-page-1/#comment-407</link>
		<dc:creator>David</dc:creator>
		<pubDate>Tue, 21 Apr 2009 11:47:33 +0000</pubDate>
		<guid isPermaLink="false">http://stereointeractive.com/blog/?p=193#comment-407</guid>
		<description>@Scott: using the symfony event notification system for this is exactly what I&#039;d also propose. Yet another configuration file for the caches is probably a solution, but I would prefer something a little less redundant.

What about placing some kind of comment (like PHPDoc) at the beginning of each template, stating what objects are used inside this template? Of course this has to be kept up-to-date as well, but it&#039;s much easier IMHO than having this in a different file. And there would be one more advantage: if you remove the template, the system won&#039;t try to remove its cache any more. So you are more able to re-use stuff as long as you use the same cache cleanup mechanism everywhere.</description>
		<content:encoded><![CDATA[<p>@Scott: using the symfony event notification system for this is exactly what I&#8217;d also propose. Yet another configuration file for the caches is probably a solution, but I would prefer something a little less redundant.</p>
<p>What about placing some kind of comment (like PHPDoc) at the beginning of each template, stating what objects are used inside this template? Of course this has to be kept up-to-date as well, but it&#8217;s much easier IMHO than having this in a different file. And there would be one more advantage: if you remove the template, the system won&#8217;t try to remove its cache any more. So you are more able to re-use stuff as long as you use the same cache cleanup mechanism everywhere.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Meves</title>
		<link>http://stereointeractive.com/blog/2009/04/10/symfony-cache-system-cache-growing-too-large/comment-page-1/#comment-405</link>
		<dc:creator>Scott Meves</dc:creator>
		<pubDate>Fri, 17 Apr 2009 14:39:32 +0000</pubDate>
		<guid isPermaLink="false">http://stereointeractive.com/blog/?p=193#comment-405</guid>
		<description>@David, I agree. In theory this type of cache clearing should occur in the controller, but the problem with that is there are potentially many different actions that affect the same objects in your model. The logical place to put an event trigger anytime an object is saved is the $myModelObj-&gt;save() method, don&#039;t you think? Maybe the solution is to abstract this clearCache method found in each model class and create an event listener that applies to all save() methods. Then, to avoid putting any mention of templates in the model, you could create a config file that contains a list of templates that are related to each data type. An interesting problem I ran into with this is that you don&#039;t have the option to include any custom logic for the cache-clearing for a particular model. For example, if you have a &quot;photo&quot; object and it may or may not be related to a &quot;user&quot;, if a photo was saved and it was related to a user, you may have to clear out the user profile cache too, but if it&#039;s related to a &quot;business&quot;, you would want to clear out a different partial from the cache. With that said, the cost of just blindly removing all the potentially cache files whenever an object is saved is probably not worth worrying about.</description>
		<content:encoded><![CDATA[<p>@David, I agree. In theory this type of cache clearing should occur in the controller, but the problem with that is there are potentially many different actions that affect the same objects in your model. The logical place to put an event trigger anytime an object is saved is the $myModelObj->save() method, don&#8217;t you think? Maybe the solution is to abstract this clearCache method found in each model class and create an event listener that applies to all save() methods. Then, to avoid putting any mention of templates in the model, you could create a config file that contains a list of templates that are related to each data type. An interesting problem I ran into with this is that you don&#8217;t have the option to include any custom logic for the cache-clearing for a particular model. For example, if you have a &#8220;photo&#8221; object and it may or may not be related to a &#8220;user&#8221;, if a photo was saved and it was related to a user, you may have to clear out the user profile cache too, but if it&#8217;s related to a &#8220;business&#8221;, you would want to clear out a different partial from the cache. With that said, the cost of just blindly removing all the potentially cache files whenever an object is saved is probably not worth worrying about.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Meves</title>
		<link>http://stereointeractive.com/blog/2009/04/10/symfony-cache-system-cache-growing-too-large/comment-page-1/#comment-404</link>
		<dc:creator>Scott Meves</dc:creator>
		<pubDate>Fri, 17 Apr 2009 14:13:25 +0000</pubDate>
		<guid isPermaLink="false">http://stereointeractive.com/blog/?p=193#comment-404</guid>
		<description>Another useful link for people landing on this post: If your routing cache is getting too large in symfony 1.2, read this: http://www.symfony-project.org/blog/2009/04/03/lazy-routing-deserialization</description>
		<content:encoded><![CDATA[<p>Another useful link for people landing on this post: If your routing cache is getting too large in symfony 1.2, read this: <a href="http://www.symfony-project.org/blog/2009/04/03/lazy-routing-deserialization" rel="nofollow">http://www.symfony-project.org/blog/2009/04/03/lazy-routing-deserialization</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yuriy Voziy</title>
		<link>http://stereointeractive.com/blog/2009/04/10/symfony-cache-system-cache-growing-too-large/comment-page-1/#comment-403</link>
		<dc:creator>Yuriy Voziy</dc:creator>
		<pubDate>Thu, 16 Apr 2009 00:29:20 +0000</pubDate>
		<guid isPermaLink="false">http://stereointeractive.com/blog/?p=193#comment-403</guid>
		<description>Clearing cross-app cache with cache manager was impossible in Symofny1.0. But it is possible now http://www.symfony-project.org/book/1_2/12-Caching#chapter_12_sub_clearing-cache-across-applications-new-in-symfony-1-1</description>
		<content:encoded><![CDATA[<p>Clearing cross-app cache with cache manager was impossible in Symofny1.0. But it is possible now <a href="http://www.symfony-project.org/book/1_2/12-Caching#chapter_12_sub_clearing-cache-across-applications-new-in-symfony-1-1" rel="nofollow">http://www.symfony-project.org/book/1_2/12-Caching#chapter_12_sub_clearing-cache-across-applications-new-in-symfony-1-1</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pages tagged "image"</title>
		<link>http://stereointeractive.com/blog/2009/04/10/symfony-cache-system-cache-growing-too-large/comment-page-1/#comment-402</link>
		<dc:creator>Pages tagged "image"</dc:creator>
		<pubDate>Sun, 12 Apr 2009 23:49:55 +0000</pubDate>
		<guid isPermaLink="false">http://stereointeractive.com/blog/?p=193#comment-402</guid>
		<description>[...] bookmarks tagged image Stereo Interactive &amp; Design &quot; symfony ca...&#160;saved by 11 others  &#160;&#160;&#160;&#160;KeroChanRules bookmarked on 04/12/09 &#124; [...]</description>
		<content:encoded><![CDATA[<p>[...] bookmarks tagged image Stereo Interactive &#38; Design &quot; symfony ca&#8230;&nbsp;saved by 11 others  &nbsp;&nbsp;&nbsp;&nbsp;KeroChanRules bookmarked on 04/12/09 | [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
