You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Dan Adams (JIRA)" <de...@tapestry.apache.org> on 2008/03/08 14:33:46 UTC

[jira] Created: (TAPESTRY-2244) Add @Once annotiation for caching method values

Add @Once annotiation 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.11
            Reporter: Dan Adams
            Assignee: Dan Adams


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


[jira] Commented: (TAPESTRY-2244) Add @Cached annotation for caching method values

Posted by "Andreas Andreou (JIRA)" <de...@tapestry.apache.org>.
    [ https://issues.apache.org/jira/browse/TAPESTRY-2244?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12576628#action_12576628 ] 

Andreas Andreou commented on TAPESTRY-2244:
-------------------------------------------

I did Cached for T4.1 @ tacos... The only undocumented feature it has is that
upon rewinding, if a value is cached, it'll also be cached during the forthcoming rendering
(assuming no redirect-after-post)

I don't know if this also happens in T5, but if it does, it's worth an explanation. For tacos, i'm
considering adding a flag like @Cached(clearOnRender=true)   if you have a better name, please share


> 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.11
>            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


[jira] Commented: (TAPESTRY-2244) Add @Cached annotation for caching method values

Posted by "Andreas Andreou (JIRA)" <de...@tapestry.apache.org>.
    [ https://issues.apache.org/jira/browse/TAPESTRY-2244?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12576681#action_12576681 ] 

Andreas Andreou commented on TAPESTRY-2244:
-------------------------------------------

So, does this mean that it suffers from the same issue/feature, or not?

I've read that T5 doesn't rewind, so i dont know if getEntities() will ever get called
BEFORE the form ends processing, but if it does, then the issue/feature i describe will exist.

For reference, here's the T4 situation:
Assuming a form that displays a list of entities and also allows me to add a new one
and i do submit a new one, here's what will happen:
- the new entity will be added to the db.
- the rendering of the page will NOT show me the new entity
because getEntities() will (probably - depends on how components are laid out) 
have been cached before 

> 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


[jira] Commented: (TAPESTRY-2244) Add @Cached annotation for caching method values

Posted by "Dan Adams (JIRA)" <de...@tapestry.apache.org>.
    [ https://issues.apache.org/jira/browse/TAPESTRY-2244?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12576674#action_12576674 ] 

Dan Adams commented on TAPESTRY-2244:
-------------------------------------

The cached value is erased when the page is detached.

> 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.11
>            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


[jira] Closed: (TAPESTRY-2244) Add @Once annotiation for caching method values

Posted by "Dan Adams (JIRA)" <de...@tapestry.apache.org>.
     [ https://issues.apache.org/jira/browse/TAPESTRY-2244?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Adams closed TAPESTRY-2244.
-------------------------------

       Resolution: Fixed
    Fix Version/s: 5.0.11

> Add @Once annotiation 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.11
>            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


[jira] Commented: (TAPESTRY-2244) Add @Cached annotation for caching method values

Posted by "Dan Adams (JIRA)" <de...@tapestry.apache.org>.
    [ 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


[jira] Reopened: (TAPESTRY-2244) Add @Once annotation for caching method values

Posted by "Dan Adams (JIRA)" <de...@tapestry.apache.org>.
     [ https://issues.apache.org/jira/browse/TAPESTRY-2244?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Adams reopened TAPESTRY-2244:
---------------------------------


At Kevin's suggestion I'm going to change the name to 'Cached'.

> Add @Once 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.11
>            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


[jira] Updated: (TAPESTRY-2244) Add @Cached annotation for caching method values

Posted by "Dan Adams (JIRA)" <de...@tapestry.apache.org>.
     [ https://issues.apache.org/jira/browse/TAPESTRY-2244?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Adams updated TAPESTRY-2244:
--------------------------------

    Summary: Add @Cached annotation for caching method values  (was: Add @Once annotation for caching method values)

> 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.11
>            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


[jira] Commented: (TAPESTRY-2244) Add @Once annotation for caching method values

Posted by "Kevin Menard (JIRA)" <de...@tapestry.apache.org>.
    [ https://issues.apache.org/jira/browse/TAPESTRY-2244?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12576620#action_12576620 ] 

Kevin Menard commented on TAPESTRY-2244:
----------------------------------------

This seems very similar to the Tacos Cached annotation:

http://tacos.sourceforge.net/tacos4.1/tacos-annotations/index.html

Any chance we could maintain name parity?

> Add @Once 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.11
>            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


[jira] Updated: (TAPESTRY-2244) Add @Cached annotation for caching method values

Posted by "Dan Adams (JIRA)" <de...@tapestry.apache.org>.
     [ https://issues.apache.org/jira/browse/TAPESTRY-2244?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Adams updated TAPESTRY-2244:
--------------------------------

    Affects Version/s:     (was: 5.0.11)
                       5.0.10

> 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


[jira] Closed: (TAPESTRY-2244) Add @Cached annotation for caching method values

Posted by "Dan Adams (JIRA)" <de...@tapestry.apache.org>.
     [ https://issues.apache.org/jira/browse/TAPESTRY-2244?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Adams closed TAPESTRY-2244.
-------------------------------

    Resolution: Fixed

> 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


[jira] Updated: (TAPESTRY-2244) Add @Once annotation for caching method values

Posted by "Dan Adams (JIRA)" <de...@tapestry.apache.org>.
     [ https://issues.apache.org/jira/browse/TAPESTRY-2244?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Adams updated TAPESTRY-2244:
--------------------------------

    Summary: Add @Once annotation for caching method values  (was: Add @Once annotiation for caching method values)

> Add @Once 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.11
>            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