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 <[EMAIL PROTECTED]> 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 <[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]
>
>

Reply via email to