You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Edvin Syse <ed...@sysedata.no> on 2008/08/26 11:28:27 UTC
Calls to MarkupCache#putIntoCache does not use the key provided by
MarkupCacheKeyProvider
Hi,
I have a virtualhosted CMS written in Wicket 1.3 where some of the pages
are loaded from the database. This is done using a custom
ResourceStreamLocator, configured in the Application#init method. This
works good.
Different users have different templates loaded for the same Wicket
page, so I need to provide a custom cache key so that instance #2
doesn't get the template loaded for instance #1. Therefore I have
overriden the MarkupCache class to be able to override the
MarkupCacheKeyProvider. This also works, my CacheKeyProvider is
consulted, but not always used for MarkupCache#putIntoCache(). Shouldn't
the key returned from the CacheKeyProvider always be used when calling
putIntoCache()?
Here is my MarkupCache implementation:
public class TornadoMarkupCache extends MarkupCache {
private IMarkupCacheKeyProvider markupCacheKeyProvider;
public TornadoMarkupCache(Application application) {
super(application);
}
protected Markup putIntoCache(String locationString, Markup markup) {
System.out.println("Putting " + locationString + " into cache");
return super.putIntoCache(locationString, markup);
}
public IMarkupCacheKeyProvider
getMarkupCacheKeyProvider(MarkupContainer container) {
if (container instanceof IMarkupCacheKeyProvider) {
return (IMarkupCacheKeyProvider)container;
}
if (markupCacheKeyProvider == null) {
markupCacheKeyProvider = new TornadoMarkupCacheKeyProvider();
}
return markupCacheKeyProvider;
}
}
And here is my CacheKeyProvider:
public class TornadoMarkupCacheKeyProvider extends
DefaultMarkupCacheKeyProvider {
public String getCacheKey(MarkupContainer container, Class clazz) {
String key = TornadoSession.get().getInstanceId() + "/" +
super.getCacheKey(container, clazz);
System.out.println("Setting key " + key);
return key;
}
}
I typically see things like this:
Setting key 1/no.sysedata.wicket.components.InfoPanelnohtml
Putting
file:/C:/Users/edvin/projects/tornado/target/classes/no/sysedata/wicket/components/InfoPanel.html
into cache
.. so it seems the CacheKeyProvider is consulted, but the key is not
used for MarkupCache#putInfoCache()
Can someone point me to what I'm missing?
Thanks!
--
Edvin Syse
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Calls to MarkupCache#putIntoCache does not use the key provided by MarkupCacheKeyProvider
Posted by Johan Compagner <jc...@gmail.com>.
as i just replied in another email
if the location string cant be extracted from the stream, which is the case
when nothing is found...
then the cacheKey is used
johan
On Tue, Aug 26, 2008 at 12:02 PM, Edvin Syse <ed...@sysedata.no> wrote:
> Hi again, Johan,
>
> I've found something disturbing:
>
> MarkupCache#onMarkupNotFound calls putIntoCache(cacheKey,
> Markup.NO_MARKUP), but putIntoCache has arguments (final String
> locationString, Markup markup). In my book that seems like the concepts of
> cacheKey and locationString are mixed. Is this really correct?
>
> protected Markup onMarkupNotFound(final String cacheKey, final
> MarkupContainer container)
> {
> if (log.isDebugEnabled())
> {
> log.debug("Markup not found: " + cacheKey);
> }
>
> // flag markup as non-existent
> return putIntoCache(cacheKey, Markup.NO_MARKUP);
> }
>
> protected Markup putIntoCache(final String locationString, Markup markup)
> {
> if (locationString != null)
> {
> if (markupCache.containsKey(locationString) == false)
> {
> markupCache.put(locationString, markup);
> }
> else
> {
> // We don't lock the cache while loading a markup. Thus it
> may
> // happen that the very same markup gets loaded twice (the
> first
> // markup being loaded, but not yet in the cache, and another
> // request requesting the very same markup). Since markup
> // loading in avg takes less than 100ms, it is not really an
> // issue. For consistency reasons however, we should always
> use
> // the markup loaded first which is why it gets returned.
> markup = (Markup)markupCache.get(locationString);
> }
> }
> return markup;
> }
>
> Johan Compagner skrev:
>
> put into cache gets the LocationString not the markupCacheKey
>> Because MarkupCache uses 2 maps
>>
>> CacheKey->LocationString
>> LocationString->Markup
>>
>> so that we dont get multiply markup objects for the same markup file.
>> (location)
>>
>> johan
>>
>>
>> On Tue, Aug 26, 2008 at 11:28 AM, Edvin Syse <ed...@sysedata.no> wrote:
>>
>>
>>
>>> Hi,
>>>
>>> I have a virtualhosted CMS written in Wicket 1.3 where some of the pages
>>> are loaded from the database. This is done using a custom
>>> ResourceStreamLocator, configured in the Application#init method. This
>>> works
>>> good.
>>>
>>> Different users have different templates loaded for the same Wicket page,
>>> so I need to provide a custom cache key so that instance #2 doesn't get
>>> the
>>> template loaded for instance #1. Therefore I have overriden the
>>> MarkupCache
>>> class to be able to override the MarkupCacheKeyProvider. This also works,
>>> my
>>> CacheKeyProvider is consulted, but not always used for
>>> MarkupCache#putIntoCache(). Shouldn't the key returned from the
>>> CacheKeyProvider always be used when calling putIntoCache()?
>>>
>>> Here is my MarkupCache implementation:
>>>
>>> public class TornadoMarkupCache extends MarkupCache {
>>> private IMarkupCacheKeyProvider markupCacheKeyProvider;
>>>
>>> public TornadoMarkupCache(Application application) {
>>> super(application);
>>> }
>>>
>>> protected Markup putIntoCache(String locationString, Markup markup) {
>>> System.out.println("Putting " + locationString + " into cache");
>>> return super.putIntoCache(locationString, markup);
>>> }
>>>
>>> public IMarkupCacheKeyProvider getMarkupCacheKeyProvider(MarkupContainer
>>> container) {
>>> if (container instanceof IMarkupCacheKeyProvider) {
>>> return (IMarkupCacheKeyProvider)container;
>>> }
>>> if (markupCacheKeyProvider == null) {
>>> markupCacheKeyProvider = new TornadoMarkupCacheKeyProvider();
>>> }
>>>
>>> return markupCacheKeyProvider;
>>> }
>>>
>>> }
>>>
>>> And here is my CacheKeyProvider:
>>>
>>> public class TornadoMarkupCacheKeyProvider extends
>>> DefaultMarkupCacheKeyProvider {
>>> public String getCacheKey(MarkupContainer container, Class clazz) {
>>> String key = TornadoSession.get().getInstanceId() + "/" +
>>> super.getCacheKey(container, clazz);
>>> System.out.println("Setting key " + key);
>>> return key;
>>> }
>>> }
>>>
>>> I typically see things like this:
>>>
>>> Setting key 1/no.sysedata.wicket.components.InfoPanelnohtml
>>>
>>> Putting
>>>
>>> file:/C:/Users/edvin/projects/tornado/target/classes/no/sysedata/wicket/components/InfoPanel.html
>>> into cache
>>>
>>> .. so it seems the CacheKeyProvider is consulted, but the key is not used
>>> for MarkupCache#putInfoCache()
>>>
>>> Can someone point me to what I'm missing?
>>>
>>> Thanks!
>>>
>>> --
>>> Edvin Syse
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>
> --
> Med vennlig hilsen
>
> Edvin Syse
> Programutvikler
>
> www.sysedata.no / edvin@sysedata.no
> Tlf: 333 49700 / Faks: 333 49701
> Adresse: Møllegaten 12, 3111 Tønsberg
>
> Syse Data AS -Profesjonelle IT-tjenester
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Calls to MarkupCache#putIntoCache does not use the key provided
by MarkupCacheKeyProvider
Posted by Edvin Syse <ed...@sysedata.no>.
Hi again, Johan,
I've found something disturbing:
MarkupCache#onMarkupNotFound calls putIntoCache(cacheKey,
Markup.NO_MARKUP), but putIntoCache has arguments (final String
locationString, Markup markup). In my book that seems like the concepts
of cacheKey and locationString are mixed. Is this really correct?
protected Markup onMarkupNotFound(final String cacheKey, final
MarkupContainer container)
{
if (log.isDebugEnabled())
{
log.debug("Markup not found: " + cacheKey);
}
// flag markup as non-existent
return putIntoCache(cacheKey, Markup.NO_MARKUP);
}
protected Markup putIntoCache(final String locationString, Markup
markup)
{
if (locationString != null)
{
if (markupCache.containsKey(locationString) == false)
{
markupCache.put(locationString, markup);
}
else
{
// We don't lock the cache while loading a markup. Thus
it may
// happen that the very same markup gets loaded twice
(the first
// markup being loaded, but not yet in the cache, and
another
// request requesting the very same markup). Since markup
// loading in avg takes less than 100ms, it is not really an
// issue. For consistency reasons however, we should
always use
// the markup loaded first which is why it gets returned.
markup = (Markup)markupCache.get(locationString);
}
}
return markup;
}
Johan Compagner skrev:
> put into cache gets the LocationString not the markupCacheKey
> Because MarkupCache uses 2 maps
>
> CacheKey->LocationString
> LocationString->Markup
>
> so that we dont get multiply markup objects for the same markup file.
> (location)
>
> johan
>
>
> On Tue, Aug 26, 2008 at 11:28 AM, Edvin Syse <ed...@sysedata.no> wrote:
>
>
>> Hi,
>>
>> I have a virtualhosted CMS written in Wicket 1.3 where some of the pages
>> are loaded from the database. This is done using a custom
>> ResourceStreamLocator, configured in the Application#init method. This works
>> good.
>>
>> Different users have different templates loaded for the same Wicket page,
>> so I need to provide a custom cache key so that instance #2 doesn't get the
>> template loaded for instance #1. Therefore I have overriden the MarkupCache
>> class to be able to override the MarkupCacheKeyProvider. This also works, my
>> CacheKeyProvider is consulted, but not always used for
>> MarkupCache#putIntoCache(). Shouldn't the key returned from the
>> CacheKeyProvider always be used when calling putIntoCache()?
>>
>> Here is my MarkupCache implementation:
>>
>> public class TornadoMarkupCache extends MarkupCache {
>> private IMarkupCacheKeyProvider markupCacheKeyProvider;
>>
>> public TornadoMarkupCache(Application application) {
>> super(application);
>> }
>>
>> protected Markup putIntoCache(String locationString, Markup markup) {
>> System.out.println("Putting " + locationString + " into cache");
>> return super.putIntoCache(locationString, markup);
>> }
>>
>> public IMarkupCacheKeyProvider getMarkupCacheKeyProvider(MarkupContainer
>> container) {
>> if (container instanceof IMarkupCacheKeyProvider) {
>> return (IMarkupCacheKeyProvider)container;
>> }
>> if (markupCacheKeyProvider == null) {
>> markupCacheKeyProvider = new TornadoMarkupCacheKeyProvider();
>> }
>>
>> return markupCacheKeyProvider;
>> }
>>
>> }
>>
>> And here is my CacheKeyProvider:
>>
>> public class TornadoMarkupCacheKeyProvider extends
>> DefaultMarkupCacheKeyProvider {
>> public String getCacheKey(MarkupContainer container, Class clazz) {
>> String key = TornadoSession.get().getInstanceId() + "/" +
>> super.getCacheKey(container, clazz);
>> System.out.println("Setting key " + key);
>> return key;
>> }
>> }
>>
>> I typically see things like this:
>>
>> Setting key 1/no.sysedata.wicket.components.InfoPanelnohtml
>>
>> Putting
>> file:/C:/Users/edvin/projects/tornado/target/classes/no/sysedata/wicket/components/InfoPanel.html
>> into cache
>>
>> .. so it seems the CacheKeyProvider is consulted, but the key is not used
>> for MarkupCache#putInfoCache()
>>
>> Can someone point me to what I'm missing?
>>
>> Thanks!
>>
>> --
>> Edvin Syse
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
>
--
Med vennlig hilsen
Edvin Syse
Programutvikler
www.sysedata.no / edvin@sysedata.no
Tlf: 333 49700 / Faks: 333 49701
Adresse: Møllegaten 12, 3111 Tønsberg
Syse Data AS -Profesjonelle IT-tjenester
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Calls to MarkupCache#putIntoCache does not use the key provided
by MarkupCacheKeyProvider
Posted by Edvin Syse <ed...@sysedata.no>.
Johan Compagner skrev:
> the locationString comes from the markup
> If that is not given by the markup stream it will fallback to the cache key
>
Aha. OK, that makes sense :)
The database-backed page is a basepage extended by other pages, so let's
say DbPage is loaded from a database, but MyPage which extends DbPage is
always the same (from the filesystem). DbPage will get the instanceid/
prefix for the cachekey, as it has no locationString, but MyPage will be
cached using the file-location-string. Since MyPage is supposed to show
different content depending on the markup of BasePage, I guess I can't
put that in the cache at all then?
-- Edvin
> and it would be very strange in my eyes if 1 stream (the same) has multiply
> locations
> at least the default MarkupStreams (based on files)
>
> johan
>
>
> On Tue, Aug 26, 2008 at 11:53 AM, Edvin Syse <ed...@sysedata.no> wrote:
>
>
>> Hi Johan,
>>
>> OK, so I need to override the LocationString to also include my unique
>> prefix somehow? Where should I do that?
>>
>> -- Edvin
>>
>> Johan Compagner skrev:
>>
>> put into cache gets the LocationString not the markupCacheKey
>>
>>> Because MarkupCache uses 2 maps
>>>
>>> CacheKey->LocationString
>>> LocationString->Markup
>>>
>>> so that we dont get multiply markup objects for the same markup file.
>>> (location)
>>>
>>> johan
>>>
>>>
>>> On Tue, Aug 26, 2008 at 11:28 AM, Edvin Syse <ed...@sysedata.no> wrote:
>>>
>>>
>>>
>>>
>>>> Hi,
>>>>
>>>> I have a virtualhosted CMS written in Wicket 1.3 where some of the pages
>>>> are loaded from the database. This is done using a custom
>>>> ResourceStreamLocator, configured in the Application#init method. This
>>>> works
>>>> good.
>>>>
>>>> Different users have different templates loaded for the same Wicket page,
>>>> so I need to provide a custom cache key so that instance #2 doesn't get
>>>> the
>>>> template loaded for instance #1. Therefore I have overriden the
>>>> MarkupCache
>>>> class to be able to override the MarkupCacheKeyProvider. This also works,
>>>> my
>>>> CacheKeyProvider is consulted, but not always used for
>>>> MarkupCache#putIntoCache(). Shouldn't the key returned from the
>>>> CacheKeyProvider always be used when calling putIntoCache()?
>>>>
>>>> Here is my MarkupCache implementation:
>>>>
>>>> public class TornadoMarkupCache extends MarkupCache {
>>>> private IMarkupCacheKeyProvider markupCacheKeyProvider;
>>>>
>>>> public TornadoMarkupCache(Application application) {
>>>> super(application);
>>>> }
>>>>
>>>> protected Markup putIntoCache(String locationString, Markup markup) {
>>>> System.out.println("Putting " + locationString + " into cache");
>>>> return super.putIntoCache(locationString, markup);
>>>> }
>>>>
>>>> public IMarkupCacheKeyProvider getMarkupCacheKeyProvider(MarkupContainer
>>>> container) {
>>>> if (container instanceof IMarkupCacheKeyProvider) {
>>>> return (IMarkupCacheKeyProvider)container;
>>>> }
>>>> if (markupCacheKeyProvider == null) {
>>>> markupCacheKeyProvider = new TornadoMarkupCacheKeyProvider();
>>>> }
>>>>
>>>> return markupCacheKeyProvider;
>>>> }
>>>>
>>>> }
>>>>
>>>> And here is my CacheKeyProvider:
>>>>
>>>> public class TornadoMarkupCacheKeyProvider extends
>>>> DefaultMarkupCacheKeyProvider {
>>>> public String getCacheKey(MarkupContainer container, Class clazz) {
>>>> String key = TornadoSession.get().getInstanceId() + "/" +
>>>> super.getCacheKey(container, clazz);
>>>> System.out.println("Setting key " + key);
>>>> return key;
>>>> }
>>>> }
>>>>
>>>> I typically see things like this:
>>>>
>>>> Setting key 1/no.sysedata.wicket.components.InfoPanelnohtml
>>>>
>>>> Putting
>>>>
>>>> file:/C:/Users/edvin/projects/tornado/target/classes/no/sysedata/wicket/components/InfoPanel.html
>>>> into cache
>>>>
>>>> .. so it seems the CacheKeyProvider is consulted, but the key is not used
>>>> for MarkupCache#putInfoCache()
>>>>
>>>> Can someone point me to what I'm missing?
>>>>
>>>> Thanks!
>>>>
>>>> --
>>>> Edvin Syse
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>> --
>> Med vennlig hilsen
>>
>> Edvin Syse
>> Programutvikler
>>
>> www.sysedata.no / edvin@sysedata.no
>> Tlf: 333 49700 / Faks: 333 49701
>> Adresse: Møllegaten 12, 3111 Tønsberg
>>
>> Syse Data AS -Profesjonelle IT-tjenester
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
>
--
Med vennlig hilsen
Edvin Syse
Programutvikler
www.sysedata.no / edvin@sysedata.no
Tlf: 333 49700 / Faks: 333 49701
Adresse: Møllegaten 12, 3111 Tønsberg
Syse Data AS -Profesjonelle IT-tjenester
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Calls to MarkupCache#putIntoCache does not use the key provided by MarkupCacheKeyProvider
Posted by Johan Compagner <jc...@gmail.com>.
the locationString comes from the markup
If that is not given by the markup stream it will fallback to the cache key
and it would be very strange in my eyes if 1 stream (the same) has multiply
locations
at least the default MarkupStreams (based on files)
johan
On Tue, Aug 26, 2008 at 11:53 AM, Edvin Syse <ed...@sysedata.no> wrote:
> Hi Johan,
>
> OK, so I need to override the LocationString to also include my unique
> prefix somehow? Where should I do that?
>
> -- Edvin
>
> Johan Compagner skrev:
>
> put into cache gets the LocationString not the markupCacheKey
>> Because MarkupCache uses 2 maps
>>
>> CacheKey->LocationString
>> LocationString->Markup
>>
>> so that we dont get multiply markup objects for the same markup file.
>> (location)
>>
>> johan
>>
>>
>> On Tue, Aug 26, 2008 at 11:28 AM, Edvin Syse <ed...@sysedata.no> wrote:
>>
>>
>>
>>> Hi,
>>>
>>> I have a virtualhosted CMS written in Wicket 1.3 where some of the pages
>>> are loaded from the database. This is done using a custom
>>> ResourceStreamLocator, configured in the Application#init method. This
>>> works
>>> good.
>>>
>>> Different users have different templates loaded for the same Wicket page,
>>> so I need to provide a custom cache key so that instance #2 doesn't get
>>> the
>>> template loaded for instance #1. Therefore I have overriden the
>>> MarkupCache
>>> class to be able to override the MarkupCacheKeyProvider. This also works,
>>> my
>>> CacheKeyProvider is consulted, but not always used for
>>> MarkupCache#putIntoCache(). Shouldn't the key returned from the
>>> CacheKeyProvider always be used when calling putIntoCache()?
>>>
>>> Here is my MarkupCache implementation:
>>>
>>> public class TornadoMarkupCache extends MarkupCache {
>>> private IMarkupCacheKeyProvider markupCacheKeyProvider;
>>>
>>> public TornadoMarkupCache(Application application) {
>>> super(application);
>>> }
>>>
>>> protected Markup putIntoCache(String locationString, Markup markup) {
>>> System.out.println("Putting " + locationString + " into cache");
>>> return super.putIntoCache(locationString, markup);
>>> }
>>>
>>> public IMarkupCacheKeyProvider getMarkupCacheKeyProvider(MarkupContainer
>>> container) {
>>> if (container instanceof IMarkupCacheKeyProvider) {
>>> return (IMarkupCacheKeyProvider)container;
>>> }
>>> if (markupCacheKeyProvider == null) {
>>> markupCacheKeyProvider = new TornadoMarkupCacheKeyProvider();
>>> }
>>>
>>> return markupCacheKeyProvider;
>>> }
>>>
>>> }
>>>
>>> And here is my CacheKeyProvider:
>>>
>>> public class TornadoMarkupCacheKeyProvider extends
>>> DefaultMarkupCacheKeyProvider {
>>> public String getCacheKey(MarkupContainer container, Class clazz) {
>>> String key = TornadoSession.get().getInstanceId() + "/" +
>>> super.getCacheKey(container, clazz);
>>> System.out.println("Setting key " + key);
>>> return key;
>>> }
>>> }
>>>
>>> I typically see things like this:
>>>
>>> Setting key 1/no.sysedata.wicket.components.InfoPanelnohtml
>>>
>>> Putting
>>>
>>> file:/C:/Users/edvin/projects/tornado/target/classes/no/sysedata/wicket/components/InfoPanel.html
>>> into cache
>>>
>>> .. so it seems the CacheKeyProvider is consulted, but the key is not used
>>> for MarkupCache#putInfoCache()
>>>
>>> Can someone point me to what I'm missing?
>>>
>>> Thanks!
>>>
>>> --
>>> Edvin Syse
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>
> --
> Med vennlig hilsen
>
> Edvin Syse
> Programutvikler
>
> www.sysedata.no / edvin@sysedata.no
> Tlf: 333 49700 / Faks: 333 49701
> Adresse: Møllegaten 12, 3111 Tønsberg
>
> Syse Data AS -Profesjonelle IT-tjenester
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Calls to MarkupCache#putIntoCache does not use the key provided
by MarkupCacheKeyProvider
Posted by Edvin Syse <ed...@sysedata.no>.
Hi Johan,
OK, so I need to override the LocationString to also include my unique
prefix somehow? Where should I do that?
-- Edvin
Johan Compagner skrev:
> put into cache gets the LocationString not the markupCacheKey
> Because MarkupCache uses 2 maps
>
> CacheKey->LocationString
> LocationString->Markup
>
> so that we dont get multiply markup objects for the same markup file.
> (location)
>
> johan
>
>
> On Tue, Aug 26, 2008 at 11:28 AM, Edvin Syse <ed...@sysedata.no> wrote:
>
>
>> Hi,
>>
>> I have a virtualhosted CMS written in Wicket 1.3 where some of the pages
>> are loaded from the database. This is done using a custom
>> ResourceStreamLocator, configured in the Application#init method. This works
>> good.
>>
>> Different users have different templates loaded for the same Wicket page,
>> so I need to provide a custom cache key so that instance #2 doesn't get the
>> template loaded for instance #1. Therefore I have overriden the MarkupCache
>> class to be able to override the MarkupCacheKeyProvider. This also works, my
>> CacheKeyProvider is consulted, but not always used for
>> MarkupCache#putIntoCache(). Shouldn't the key returned from the
>> CacheKeyProvider always be used when calling putIntoCache()?
>>
>> Here is my MarkupCache implementation:
>>
>> public class TornadoMarkupCache extends MarkupCache {
>> private IMarkupCacheKeyProvider markupCacheKeyProvider;
>>
>> public TornadoMarkupCache(Application application) {
>> super(application);
>> }
>>
>> protected Markup putIntoCache(String locationString, Markup markup) {
>> System.out.println("Putting " + locationString + " into cache");
>> return super.putIntoCache(locationString, markup);
>> }
>>
>> public IMarkupCacheKeyProvider getMarkupCacheKeyProvider(MarkupContainer
>> container) {
>> if (container instanceof IMarkupCacheKeyProvider) {
>> return (IMarkupCacheKeyProvider)container;
>> }
>> if (markupCacheKeyProvider == null) {
>> markupCacheKeyProvider = new TornadoMarkupCacheKeyProvider();
>> }
>>
>> return markupCacheKeyProvider;
>> }
>>
>> }
>>
>> And here is my CacheKeyProvider:
>>
>> public class TornadoMarkupCacheKeyProvider extends
>> DefaultMarkupCacheKeyProvider {
>> public String getCacheKey(MarkupContainer container, Class clazz) {
>> String key = TornadoSession.get().getInstanceId() + "/" +
>> super.getCacheKey(container, clazz);
>> System.out.println("Setting key " + key);
>> return key;
>> }
>> }
>>
>> I typically see things like this:
>>
>> Setting key 1/no.sysedata.wicket.components.InfoPanelnohtml
>>
>> Putting
>> file:/C:/Users/edvin/projects/tornado/target/classes/no/sysedata/wicket/components/InfoPanel.html
>> into cache
>>
>> .. so it seems the CacheKeyProvider is consulted, but the key is not used
>> for MarkupCache#putInfoCache()
>>
>> Can someone point me to what I'm missing?
>>
>> Thanks!
>>
>> --
>> Edvin Syse
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
>
--
Med vennlig hilsen
Edvin Syse
Programutvikler
www.sysedata.no / edvin@sysedata.no
Tlf: 333 49700 / Faks: 333 49701
Adresse: Møllegaten 12, 3111 Tønsberg
Syse Data AS -Profesjonelle IT-tjenester
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Calls to MarkupCache#putIntoCache does not use the key provided by MarkupCacheKeyProvider
Posted by Johan Compagner <jc...@gmail.com>.
put into cache gets the LocationString not the markupCacheKey
Because MarkupCache uses 2 maps
CacheKey->LocationString
LocationString->Markup
so that we dont get multiply markup objects for the same markup file.
(location)
johan
On Tue, Aug 26, 2008 at 11:28 AM, Edvin Syse <ed...@sysedata.no> wrote:
> Hi,
>
> I have a virtualhosted CMS written in Wicket 1.3 where some of the pages
> are loaded from the database. This is done using a custom
> ResourceStreamLocator, configured in the Application#init method. This works
> good.
>
> Different users have different templates loaded for the same Wicket page,
> so I need to provide a custom cache key so that instance #2 doesn't get the
> template loaded for instance #1. Therefore I have overriden the MarkupCache
> class to be able to override the MarkupCacheKeyProvider. This also works, my
> CacheKeyProvider is consulted, but not always used for
> MarkupCache#putIntoCache(). Shouldn't the key returned from the
> CacheKeyProvider always be used when calling putIntoCache()?
>
> Here is my MarkupCache implementation:
>
> public class TornadoMarkupCache extends MarkupCache {
> private IMarkupCacheKeyProvider markupCacheKeyProvider;
>
> public TornadoMarkupCache(Application application) {
> super(application);
> }
>
> protected Markup putIntoCache(String locationString, Markup markup) {
> System.out.println("Putting " + locationString + " into cache");
> return super.putIntoCache(locationString, markup);
> }
>
> public IMarkupCacheKeyProvider getMarkupCacheKeyProvider(MarkupContainer
> container) {
> if (container instanceof IMarkupCacheKeyProvider) {
> return (IMarkupCacheKeyProvider)container;
> }
> if (markupCacheKeyProvider == null) {
> markupCacheKeyProvider = new TornadoMarkupCacheKeyProvider();
> }
>
> return markupCacheKeyProvider;
> }
>
> }
>
> And here is my CacheKeyProvider:
>
> public class TornadoMarkupCacheKeyProvider extends
> DefaultMarkupCacheKeyProvider {
> public String getCacheKey(MarkupContainer container, Class clazz) {
> String key = TornadoSession.get().getInstanceId() + "/" +
> super.getCacheKey(container, clazz);
> System.out.println("Setting key " + key);
> return key;
> }
> }
>
> I typically see things like this:
>
> Setting key 1/no.sysedata.wicket.components.InfoPanelnohtml
>
> Putting
> file:/C:/Users/edvin/projects/tornado/target/classes/no/sysedata/wicket/components/InfoPanel.html
> into cache
>
> .. so it seems the CacheKeyProvider is consulted, but the key is not used
> for MarkupCache#putInfoCache()
>
> Can someone point me to what I'm missing?
>
> Thanks!
>
> --
> Edvin Syse
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Calls to MarkupCache#putIntoCache does not use the key provided
by MarkupCacheKeyProvider
Posted by Edvin Syse <ed...@sysedata.no>.
Nice, thanks :)
-- Edvin
Igor Vaynberg skrev:
> i would just let the base cms page implement imarkupcachekeyprovider
>
> -igor
>
> On Tue, Aug 26, 2008 at 2:28 AM, Edvin Syse <ed...@sysedata.no> wrote:
>> Hi,
>>
>> I have a virtualhosted CMS written in Wicket 1.3 where some of the pages are
>> loaded from the database. This is done using a custom ResourceStreamLocator,
>> configured in the Application#init method. This works good.
>>
>> Different users have different templates loaded for the same Wicket page, so
>> I need to provide a custom cache key so that instance #2 doesn't get the
>> template loaded for instance #1. Therefore I have overriden the MarkupCache
>> class to be able to override the MarkupCacheKeyProvider. This also works, my
>> CacheKeyProvider is consulted, but not always used for
>> MarkupCache#putIntoCache(). Shouldn't the key returned from the
>> CacheKeyProvider always be used when calling putIntoCache()?
>>
>> Here is my MarkupCache implementation:
>>
>> public class TornadoMarkupCache extends MarkupCache {
>> private IMarkupCacheKeyProvider markupCacheKeyProvider;
>>
>> public TornadoMarkupCache(Application application) {
>> super(application);
>> }
>>
>> protected Markup putIntoCache(String locationString, Markup markup) {
>> System.out.println("Putting " + locationString + " into cache");
>> return super.putIntoCache(locationString, markup);
>> }
>>
>> public IMarkupCacheKeyProvider getMarkupCacheKeyProvider(MarkupContainer
>> container) {
>> if (container instanceof IMarkupCacheKeyProvider) {
>> return (IMarkupCacheKeyProvider)container;
>> }
>> if (markupCacheKeyProvider == null) {
>> markupCacheKeyProvider = new TornadoMarkupCacheKeyProvider();
>> }
>>
>> return markupCacheKeyProvider;
>> }
>>
>> }
>>
>> And here is my CacheKeyProvider:
>>
>> public class TornadoMarkupCacheKeyProvider extends
>> DefaultMarkupCacheKeyProvider {
>> public String getCacheKey(MarkupContainer container, Class clazz) {
>> String key = TornadoSession.get().getInstanceId() + "/" +
>> super.getCacheKey(container, clazz);
>> System.out.println("Setting key " + key);
>> return key;
>> }
>> }
>>
>> I typically see things like this:
>>
>> Setting key 1/no.sysedata.wicket.components.InfoPanelnohtml
>>
>> Putting
>> file:/C:/Users/edvin/projects/tornado/target/classes/no/sysedata/wicket/components/InfoPanel.html
>> into cache
>>
>> .. so it seems the CacheKeyProvider is consulted, but the key is not used
>> for MarkupCache#putInfoCache()
>>
>> Can someone point me to what I'm missing?
>>
>> Thanks!
>>
>> --
>> Edvin Syse
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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: Calls to MarkupCache#putIntoCache does not use the key provided by MarkupCacheKeyProvider
Posted by Igor Vaynberg <ig...@gmail.com>.
i would just let the base cms page implement imarkupcachekeyprovider
-igor
On Tue, Aug 26, 2008 at 2:28 AM, Edvin Syse <ed...@sysedata.no> wrote:
> Hi,
>
> I have a virtualhosted CMS written in Wicket 1.3 where some of the pages are
> loaded from the database. This is done using a custom ResourceStreamLocator,
> configured in the Application#init method. This works good.
>
> Different users have different templates loaded for the same Wicket page, so
> I need to provide a custom cache key so that instance #2 doesn't get the
> template loaded for instance #1. Therefore I have overriden the MarkupCache
> class to be able to override the MarkupCacheKeyProvider. This also works, my
> CacheKeyProvider is consulted, but not always used for
> MarkupCache#putIntoCache(). Shouldn't the key returned from the
> CacheKeyProvider always be used when calling putIntoCache()?
>
> Here is my MarkupCache implementation:
>
> public class TornadoMarkupCache extends MarkupCache {
> private IMarkupCacheKeyProvider markupCacheKeyProvider;
>
> public TornadoMarkupCache(Application application) {
> super(application);
> }
>
> protected Markup putIntoCache(String locationString, Markup markup) {
> System.out.println("Putting " + locationString + " into cache");
> return super.putIntoCache(locationString, markup);
> }
>
> public IMarkupCacheKeyProvider getMarkupCacheKeyProvider(MarkupContainer
> container) {
> if (container instanceof IMarkupCacheKeyProvider) {
> return (IMarkupCacheKeyProvider)container;
> }
> if (markupCacheKeyProvider == null) {
> markupCacheKeyProvider = new TornadoMarkupCacheKeyProvider();
> }
>
> return markupCacheKeyProvider;
> }
>
> }
>
> And here is my CacheKeyProvider:
>
> public class TornadoMarkupCacheKeyProvider extends
> DefaultMarkupCacheKeyProvider {
> public String getCacheKey(MarkupContainer container, Class clazz) {
> String key = TornadoSession.get().getInstanceId() + "/" +
> super.getCacheKey(container, clazz);
> System.out.println("Setting key " + key);
> return key;
> }
> }
>
> I typically see things like this:
>
> Setting key 1/no.sysedata.wicket.components.InfoPanelnohtml
>
> Putting
> file:/C:/Users/edvin/projects/tornado/target/classes/no/sysedata/wicket/components/InfoPanel.html
> into cache
>
> .. so it seems the CacheKeyProvider is consulted, but the key is not used
> for MarkupCache#putInfoCache()
>
> Can someone point me to what I'm missing?
>
> Thanks!
>
> --
> Edvin Syse
>
>
>
> ---------------------------------------------------------------------
> 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