You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Thomas Zehetbauer <th...@hostmaster.org> on 2004/03/12 02:23:11 UTC

Eventcache - Invalidate from XSP?

Is it possible invalidate cache entries from an XSP page?

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.

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?

Regards
Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Eventcache - Invalidate from XSP?

Posted by Thomas Zehetbauer <th...@hostmaster.org>.
On Fre, 2004-03-12 at 11:57 -0500, Geoff Howard wrote:
> I'd reccomend using actions or flow for the update, xsp (or some other 
> flavor of generator) just to generate the xml version of the model.

I prefer to use Java for my code so I could only use an action, but how
do I get the information from there (eg. execution time or the number of
records updated) into a XML document for display?

> I'm being terse just because I don't have a lot of time ATM.  Feel free 
> to keep asking questions.

Your answers were helpful and your help is very much appreciated :-) I
do now have a basic but working 'cache' logicsheet that allows me to
easily add the code required for caching to a XSP, define dependencies
and invalidate dependencies.

Regards
Tom



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Eventcache - Invalidate from XSP?

Posted by Geoff Howard <co...@leverageweb.com>.
Thomas Zehetbauer wrote:

>On Fre, 2004-03-12 at 08:40 -0500, Geoff Howard wrote:
>  
>
>>Hopefully you meant an XSP action.
>>    
>>
>
>No, I mean an XSP page. I use a Java bean to update the database and
>output a XML document containing some information about this update. Do
>you recommend another approach for this task?
>  
>

I'd reccomend using actions or flow for the update, xsp (or some other 
flavor of generator) just to generate the xml version of the model.  
Doing otherwise mixes concerns IMHO.

>What I have and like is the ability to call update.html?databases=a,b or
>update.txt?databases=a,b and accordingly invalidate pages depending on
>these. I guess using actions for would make it far more difficult or
>even impossible to generate this output.
>  
>

?? Don't see why this is difficult with or without actions.  Have you 
looked over the modular db actions samples, for example?

>I wonder how it is possible to get a reference to cocoons event-aware
>cache implementation from an database trigger, do you have any working
>example for this?
>  
>

No, no.  You wouldn't use a direct reference to Cocoon's cache from 
there - you'd either fire off a jms message (see the jms block for 
examples) or you'd use http to call a pipeline which executes the 
action.   JMS is the way to go hands down if you ever need to load 
balance across several Cocoon front-ends.

I'm being terse just because I don't have a lot of time ATM.  Feel free 
to keep asking questions.

Geoff

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Eventcache - Invalidate from XSP?

Posted by Thomas Zehetbauer <th...@hostmaster.org>.
On Fre, 2004-03-12 at 08:40 -0500, Geoff Howard wrote:
> Hopefully you meant an XSP action.

No, I mean an XSP page. I use a Java bean to update the database and
output a XML document containing some information about this update. Do
you recommend another approach for this task?

What I have and like is the ability to call update.html?databases=a,b or
update.txt?databases=a,b and accordingly invalidate pages depending on
these. I guess using actions for would make it far more difficult or
even impossible to generate this output.

I wonder how it is possible to get a reference to cocoons event-aware
cache implementation from an database trigger, do you have any working
example for this?

Regards
Tom

-- 
  T h o m a s   Z e h e t b a u e r   ( TZ251 )
  PGP encrypted mail preferred - KeyID 96FFCB89
      finger thomasz@hostmaster.org for key

Because you are just paranoid doesn't mean that they aren't out to catch you!



Re: Eventcache - Invalidate from XSP?

Posted by Geoff Howard <co...@leverageweb.com>.
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 
this. 

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.

Geoff

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org