cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoff Howard <>
Subject Re: Eventcache - Invalidate from XSP?
Date Fri, 12 Mar 2004 13:40:55 GMT
Thomas Zehetbauer wrote:

>Is it possible invalidate cache entries from an XSP page?

Yes, but I'm not sure it should be encouraged....

>According to the samples one can either use flowscript (event.js) or the
>CacheEventAction to invalidate entries. I would however prefer to raise
>the necessary events directly from a XSP page, but while there is an
>implicit cocoon object in flowscript that enables one to get access the
>event-aware pipeline implementation I could not figure out how to
>implement cocoon.getComponent() in XSP.

Hopefully you meant an XSP action.  XSP Generators and XSP actions both 
inherit a reference to the ComponentManager/ServiceManager which you can 
use to look up the Cache just as the CacheEventAction does.  One could 
also override the inherited compose() method and several other lifecycle 
methods which would make this feasible.   A generator is IMILHO (in my 
increasingly less humble opinion :) ) just plain the wrong place to do 

If you are using actions, though you should seriously consider using 
nested actions to do this:

<map:act type="updateYourDatabase">
  <map:act type="uncacheEvent">
      <map:.... <!-- rest of your pipeline if successful -->

and so on.  In this case, I'm not sure why you wouldn't just use the 
existing CacheEventAction.  If you need to modify its behavior, it 
really should be trivial to do in a subclass.  If not, explain why and 
it can probably be fixed.

>To make myself more clear, I have a database which is queried from an
>XSP with the output being cached in an event-aware pipeline. Another XSP
>page modifies this database and wants to expire the affected cache
>entries. Is this possible? How?

So, yes - possible but maybe not necessary.  However, depending on the 
database you're using I'd seriously look at the option to fire these 
events directly from a db trigger on update of your database.   This way 
you are free to have any other process manipulate the database and not 
have to worry about invalid cache.  In real life, I have often had to 
resort to direct database manipulation and the confidence that all 
necessary events are fired right from there automatically is a great 
help.  Not all DBs will support this (I think Mysql does not yet) but 
worth taking a look.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message