On Sep 25, 5:39 pm, "Simon Roby" <[EMAIL PROTECTED]> wrote:

> Chapter 12 (Caching) of the sf manual talks about clearing specific
> cached actions using
> $this->getContext()->getViewCacheManager()->remove()
> but what if I want to clear them all? And preferably without clearing
> other aspects of the cache such as the configuration cache?
>
> I'm wondering this because I'm setting up action caching in my
> application, and I'd like to be able to clear all cached actions
> whenever a user is added/modified/deleted, since users are present on
> almost every page of the application.

Several thoughts here.

1. You can use globbing functions to remove selected parts of the
cache using wildcards - see clearGlob() method in sfToolkit.

2. You could also skip action caching and cache selected parts of the
page instead (i.e. parts not dependant on session data and partials
not dependant on session data).

3. Setup (2) and build a module that has actions to clear portions of
the cache depending on changes in the model data - you need to create
unique keys for the page portions you wish to clear.

I did all of the above on a large site Im working on, i.e. no action
caching; break down and analyse portions of each template then code
your templates / actions / partials to use caching when necessary; and
set cache keys for each fragment. In our case, the main site only has
a few templates so its not as hard as you might think. Whenever a user
changes data that is normally cached, the action calls another action
in a "cache clearing" module that removes the cache entry (I pass
cache key or an id used in the cache key to the clearing action). The
next time someone hits that content, the cache is regenerated
automatically. So far this scheme has worked very well (number of
queries on some pages become 0).



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to