tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Adams (JIRA)" <...@tapestry.apache.org>
Subject [jira] Commented: (TAPESTRY-2244) Add @Cached annotation for caching method values
Date Sun, 09 Mar 2008 22:21:46 GMT

    [ https://issues.apache.org/jira/browse/TAPESTRY-2244?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12576827#action_12576827

Dan Adams commented on TAPESTRY-2244:

Correct, there is no rewind in T5. I was pretty certain this wouldn't be a problem but I added
an integration test to prove it. Thanks for the heads-up on the possible problem.

> Add @Cached annotation for caching method values
> ------------------------------------------------
>                 Key: TAPESTRY-2244
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2244
>             Project: Tapestry
>          Issue Type: New Feature
>          Components: tapestry-core
>    Affects Versions: 5.0.10
>            Reporter: Dan Adams
>            Assignee: Dan Adams
>             Fix For: 5.0.11
> The @Once annotation can be used on methods to cache the value or cache the value based
on some other value changing (great for loops). We've been using it in our internal CMS library
and it's immensly useful, especially when getting things out of any kind of database or doing
queries. Here's a typical usage:
> class:
> @Once
> public List<Entities> getEntities() {
>   // get and return the objects from the database or something
> }
> in the template:
> <t:if test="!entities.empty">
>   do something
> </t:if>
> <t:loop source="entities">
>   loop through and do something
> </t:loop>
> In this example, getEntities gets cached on the if test and then the value is cached
so it doesn't get called again on the loop. You can also use it this way:
> @Property
> private Entity loopValue;
> @Once(watch="loopValue")
> public Object getSomeDependentValue() {
>   // do some expensive operation based on loopValue
> }
> which will only execute the method each time loopValue changes.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org

View raw message