You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Brown, Berlin [GCG-PFS]" <Be...@Primerica.com> on 2012/07/24 19:18:02 UTC
Really slow code
With code like this, I have a model and within the 'load' method, I am
making a slower call that I don't want to call to get the data again.
I may need the result 'bean' for another part of the UI on that
particular page and I don't want to make that call again. How can I do
this?
1. OnBeforeRender, get a reference to the component and return the
defaultmodelobject?
2. Use a field reference in my parent component to the result set?
final LoadableDetachableModel<Bean> modelReqList = new
LoadableDetachableModel<Bean>() {
public Bean load() {
return
runReallySlowCodeOnlyWantToCallOnce();
}
};
-----
Re: Really slow code
Posted by Dan Retzlaff <dr...@gmail.com>.
Pro: session is a broader scope, so query will happen less often
Con: session is serialized so cached value needs to be serializable or
transient/detached
Con: session is accessed by multiple threads simultaneously, so you need to
handle synchronization
Your call. :)
On Tue, Jul 24, 2012 at 12:46 PM, Brown, Berlin [GCG-PFS] <
Berlin.Brown@primerica.com> wrote:
> Thanks,
> I just found some code that uses 'session' as opposed to the request
> cycle for caching. Does that matter? Or is the requestcycle preferred?
>
> getSession().setMetaData
>
> -----Original Message-----
> From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Sent: Tuesday, July 24, 2012 3:20 PM
> To: users@wicket.apache.org
> Subject: Re: Really slow code
>
> static class MetaDataKey<MyData> MYDATA=new MetaDateKey<MyData>() {};
>
> ^ thats the type-safe singleton key you use to acces the metadata store
>
> checking for metadata
>
> MyData data=RequestCycle.get().getMetaData(MYDATA);
>
> ^ null means none
>
> writing metadata
>
> RequestCycle.get().setMetaData(MYDATA, data);
>
> -igor
>
>
> On Tue, Jul 24, 2012 at 9:26 PM, Brown, Berlin [GCG-PFS]
> <Be...@primerica.com> wrote:
> > You have any more specifics or an example? Is there a metadata class?
> >
> > -----Original Message-----
> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> > Sent: Tuesday, July 24, 2012 1:34 PM
> > To: users@wicket.apache.org
> > Subject: Re: Really slow code
> >
> > cache it in request cycle's metadata
> >
> > -igor
> >
> > On Tue, Jul 24, 2012 at 8:18 PM, Brown, Berlin [GCG-PFS]
> > <Be...@primerica.com> wrote:
> >> With code like this, I have a model and within the 'load' method, I
> >> am
> >
> >> making a slower call that I don't want to call to get the data again.
> >>
> >>
> >>
> >> I may need the result 'bean' for another part of the UI on that
> >> particular page and I don't want to make that call again. How can I
> >> do this?
> >>
> >>
> >>
> >> 1. OnBeforeRender, get a reference to the component and return
> > the
> >> defaultmodelobject?
> >>
> >> 2. Use a field reference in my parent component to the result
> > set?
> >>
> >>
> >>
> >> final LoadableDetachableModel<Bean> modelReqList = new
> >> LoadableDetachableModel<Bean>() {
> >>
> >> public Bean load() {
> >>
> >> return
> >> runReallySlowCodeOnlyWantToCallOnce();
> >>
> >> }
> >>
> >> };
> >>
> >>
> >>
> >> -----
> >>
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
RE: Really slow code
Posted by "Brown, Berlin [GCG-PFS]" <Be...@Primerica.com>.
Thanks,
I just found some code that uses 'session' as opposed to the request
cycle for caching. Does that matter? Or is the requestcycle preferred?
getSession().setMetaData
-----Original Message-----
From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
Sent: Tuesday, July 24, 2012 3:20 PM
To: users@wicket.apache.org
Subject: Re: Really slow code
static class MetaDataKey<MyData> MYDATA=new MetaDateKey<MyData>() {};
^ thats the type-safe singleton key you use to acces the metadata store
checking for metadata
MyData data=RequestCycle.get().getMetaData(MYDATA);
^ null means none
writing metadata
RequestCycle.get().setMetaData(MYDATA, data);
-igor
On Tue, Jul 24, 2012 at 9:26 PM, Brown, Berlin [GCG-PFS]
<Be...@primerica.com> wrote:
> You have any more specifics or an example? Is there a metadata class?
>
> -----Original Message-----
> From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Sent: Tuesday, July 24, 2012 1:34 PM
> To: users@wicket.apache.org
> Subject: Re: Really slow code
>
> cache it in request cycle's metadata
>
> -igor
>
> On Tue, Jul 24, 2012 at 8:18 PM, Brown, Berlin [GCG-PFS]
> <Be...@primerica.com> wrote:
>> With code like this, I have a model and within the 'load' method, I
>> am
>
>> making a slower call that I don't want to call to get the data again.
>>
>>
>>
>> I may need the result 'bean' for another part of the UI on that
>> particular page and I don't want to make that call again. How can I
>> do this?
>>
>>
>>
>> 1. OnBeforeRender, get a reference to the component and return
> the
>> defaultmodelobject?
>>
>> 2. Use a field reference in my parent component to the result
> set?
>>
>>
>>
>> final LoadableDetachableModel<Bean> modelReqList = new
>> LoadableDetachableModel<Bean>() {
>>
>> public Bean load() {
>>
>> return
>> runReallySlowCodeOnlyWantToCallOnce();
>>
>> }
>>
>> };
>>
>>
>>
>> -----
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Really slow code
Posted by Igor Vaynberg <ig...@gmail.com>.
static class MetaDataKey<MyData> MYDATA=new MetaDateKey<MyData>() {};
^ thats the type-safe singleton key you use to acces the metadata store
checking for metadata
MyData data=RequestCycle.get().getMetaData(MYDATA);
^ null means none
writing metadata
RequestCycle.get().setMetaData(MYDATA, data);
-igor
On Tue, Jul 24, 2012 at 9:26 PM, Brown, Berlin [GCG-PFS]
<Be...@primerica.com> wrote:
> You have any more specifics or an example? Is there a metadata class?
>
> -----Original Message-----
> From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Sent: Tuesday, July 24, 2012 1:34 PM
> To: users@wicket.apache.org
> Subject: Re: Really slow code
>
> cache it in request cycle's metadata
>
> -igor
>
> On Tue, Jul 24, 2012 at 8:18 PM, Brown, Berlin [GCG-PFS]
> <Be...@primerica.com> wrote:
>> With code like this, I have a model and within the 'load' method, I am
>
>> making a slower call that I don't want to call to get the data again.
>>
>>
>>
>> I may need the result 'bean' for another part of the UI on that
>> particular page and I don't want to make that call again. How can I
>> do this?
>>
>>
>>
>> 1. OnBeforeRender, get a reference to the component and return
> the
>> defaultmodelobject?
>>
>> 2. Use a field reference in my parent component to the result
> set?
>>
>>
>>
>> final LoadableDetachableModel<Bean> modelReqList = new
>> LoadableDetachableModel<Bean>() {
>>
>> public Bean load() {
>>
>> return
>> runReallySlowCodeOnlyWantToCallOnce();
>>
>> }
>>
>> };
>>
>>
>>
>> -----
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
RE: Really slow code
Posted by "Brown, Berlin [GCG-PFS]" <Be...@Primerica.com>.
You have any more specifics or an example? Is there a metadata class?
-----Original Message-----
From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
Sent: Tuesday, July 24, 2012 1:34 PM
To: users@wicket.apache.org
Subject: Re: Really slow code
cache it in request cycle's metadata
-igor
On Tue, Jul 24, 2012 at 8:18 PM, Brown, Berlin [GCG-PFS]
<Be...@primerica.com> wrote:
> With code like this, I have a model and within the 'load' method, I am
> making a slower call that I don't want to call to get the data again.
>
>
>
> I may need the result 'bean' for another part of the UI on that
> particular page and I don't want to make that call again. How can I
> do this?
>
>
>
> 1. OnBeforeRender, get a reference to the component and return
the
> defaultmodelobject?
>
> 2. Use a field reference in my parent component to the result
set?
>
>
>
> final LoadableDetachableModel<Bean> modelReqList = new
> LoadableDetachableModel<Bean>() {
>
> public Bean load() {
>
> return
> runReallySlowCodeOnlyWantToCallOnce();
>
> }
>
> };
>
>
>
> -----
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Really slow code
Posted by Igor Vaynberg <ig...@gmail.com>.
cache it in request cycle's metadata
-igor
On Tue, Jul 24, 2012 at 8:18 PM, Brown, Berlin [GCG-PFS]
<Be...@primerica.com> wrote:
> With code like this, I have a model and within the 'load' method, I am
> making a slower call that I don't want to call to get the data again.
>
>
>
> I may need the result 'bean' for another part of the UI on that
> particular page and I don't want to make that call again. How can I do
> this?
>
>
>
> 1. OnBeforeRender, get a reference to the component and return the
> defaultmodelobject?
>
> 2. Use a field reference in my parent component to the result set?
>
>
>
> final LoadableDetachableModel<Bean> modelReqList = new
> LoadableDetachableModel<Bean>() {
>
> public Bean load() {
>
> return
> runReallySlowCodeOnlyWantToCallOnce();
>
> }
>
> };
>
>
>
> -----
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org