You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Danny Mandel <dm...@tolweb.org> on 2004/09/21 20:19:46 UTC
appropriate time to cache component output
Hi all. I'm wondering if anyone currently has any sort of caching
systems in place to cache output for particular components given
particular inputs. Ideally I would like my completed component to
function something like this:
<span jwcid="@Conditional" condition="ognl:ifCachedOutputExists">
// Insert the cached content here
</span>
<span jwcid="@Conditional" condition="ognl:!ifCachedOutputExists">
// Perform some expensive calculations and db fetches and at the end
of this computation
// insert the ouput of this conditional into some cache
</span>
I guess I have 2 main questions:
1) Is there a particular hook in the page/component render cycle that
would be an appropriate place to insert this cache insert logic?
2) If such a hook exists, is there a way for a component to be aware of
the html it has just rendered?
Thanks,
Danny
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: appropriate time to cache component output
Posted by Kurt Zoglmann <zo...@yahoo.com>.
I'm not aware of any direct accessible caching mechanisms that you can
use from within the tapestry framework. However, your in luck because
there are several free caching mechanisms already implemented for you.
Take a look at JCS, EHCache, and OSCache for caching within a single
JVM both in disk and memory or look at SwarmCache for caching in a
cluster. I don't know too much about all of them, but I have used
EHCache and found it very easy to use and configure.
You may also want to take a look at hibernate. It is a ORM (Object
relational mapping framework) and has built in support for both session
level caching and secondary caching. If you are performing very
expensive queries, hibernate even supports query caching. I started
using hibernate a couple of months ago and have found that it has many
benefits. If you just a single page that needs to have its results
cached, I wouldn't go to all the trouble of investigating hibernate.
I've already posted something about general caching using Tapestry.
Below is what I originally suggested for someone wanting to do server
side include caching. Instead of caching raw output, you could manage
your own property that has the results of the expensive computations
and use caching on that property.
include.html
<span jwcid="@Insert" value="ognl:content" raw="true"/>
include.jwc
<component-specification class="package.Include" allow-body="yes"
allow-informal-parameters="no">
<parameter name="name" type="java.lang.String" required="true"/>
<property-specification name="content" type="java.lang.String"/>
</component>
Include.java
//use JCS or EHcache to store/cache stuff
protected void prepareForRender() {
String content;
//check if in cache
//load from filesystem if not in cache and place in cache
setContent(content);
}
public abstract void setContent(String content);
public abstract String getName();
On Sep 21, 2004, at 1:19 PM, Danny Mandel wrote:
> Hi all. I'm wondering if anyone currently has any sort of caching
> systems in place to cache output for particular components given
> particular inputs. Ideally I would like my completed component to
> function something like this:
>
> <span jwcid="@Conditional" condition="ognl:ifCachedOutputExists">
> // Insert the cached content here
> </span>
> <span jwcid="@Conditional" condition="ognl:!ifCachedOutputExists">
> // Perform some expensive calculations and db fetches and at the
> end of this computation
> // insert the ouput of this conditional into some cache
> </span>
>
> I guess I have 2 main questions:
> 1) Is there a particular hook in the page/component render cycle that
> would be an appropriate place to insert this cache insert logic?
> 2) If such a hook exists, is there a way for a component to be aware
> of the html it has just rendered?
>
> Thanks,
> Danny
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org