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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Med vennlig hilsen

Edvin Syse
Programutvikler

www.sysedata.no / [EMAIL PROTECTED]
Tlf: 333 49700  / Faks: 333 49701
Adresse: Møllegaten 12, 3111 Tønsberg

Syse Data AS -Profesjonelle IT-tjenester

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Med vennlig hilsen

Edvin Syse
Programutvikler

www.sysedata.no / [EMAIL PROTECTED]
Tlf: 333 49700  / Faks: 333 49701
Adresse: Møllegaten 12, 3111 Tønsberg

Syse Data AS -Profesjonelle IT-tjenester

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to