You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Geoffrey Wiseman <ge...@gmail.com> on 2009/03/26 20:54:44 UTC

Cached and Self-Calls

Does tapestry manipulate the page class enough that @Cached affects
self-calls?

That is, if I wrote this code:

@Cached
List<?> getSomeExpensiveResult() { ... }

String getSummary() {
  if( getSomeExpensiveResult().isEmpty() )
  return "nothing";
  else {
    String summary = "";
    for( Object item : getSomeExpensiveResult() ) {
      summary += item.toString();
    }
  }
}

Would getSummary() call getSomeExpensiveResult() twice (as it would if the
internals weren't manipulated in some way), or does Tapestry manipulate the
class enough that even that kind of use is cached?  I've always got
@SetupRender as an alternative for calculating something expensive, from
what I can tell.

  - Geoffrey
-- 
Geoffrey Wiseman
http://www.geoffreywiseman.ca/

Re: Cached and Self-Calls

Posted by Howard Lewis Ship <hl...@gmail.com>.
I believe self-calls are handled; you can use @Cached on non-public
methods as well.

On Thu, Mar 26, 2009 at 12:54 PM, Geoffrey Wiseman
<ge...@gmail.com> wrote:
> Does tapestry manipulate the page class enough that @Cached affects
> self-calls?
>
> That is, if I wrote this code:
>
> @Cached
> List<?> getSomeExpensiveResult() { ... }
>
> String getSummary() {
>  if( getSomeExpensiveResult().isEmpty() )
>  return "nothing";
>  else {
>    String summary = "";
>    for( Object item : getSomeExpensiveResult() ) {
>      summary += item.toString();
>    }
>  }
> }
>
> Would getSummary() call getSomeExpensiveResult() twice (as it would if the
> internals weren't manipulated in some way), or does Tapestry manipulate the
> class enough that even that kind of use is cached?  I've always got
> @SetupRender as an alternative for calculating something expensive, from
> what I can tell.
>
>  - Geoffrey
> --
> Geoffrey Wiseman
> http://www.geoffreywiseman.ca/
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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