From: Alex Twisleton-Wykeham-F. <al...@fi...> - 2005-03-11 14:36:05
|
All, a question this time: If I want to extend my EvaluatingTemplateLoader to play nice with the caching construct then I am a little bit confused about the logic of the CacheReloadContext. If I have the following code:- package org.cord.node; import org.webmacro.*; import org.webmacro.engine.*; import org.webmacro.resource.*; public class EvaluatingTemplateLoader extends AbstractTemplateLoader { public final static String PROTOCOL = "evaluate:"; public void setConfig(String config) { } public Template load(String query, CacheElement ce) throws ResourceException { if (! query.startsWith(PROTOCOL)) { return null; } ce.setReloadContext(new CacheReloadContext() { public boolean shouldReload() { return false; } }); return new StringTemplate(broker, query.substring(PROTOCOL.length())); } } then does that mean for a given value of query (which in this case actually holds the evaluatable content of the template) that the CacheManager will not invoke load(query,ce) on the EvaluatingTemplateLoader after the initial request? If this is the case, then will the CacheManager expire the mapping of query:StringTemplate after some time (based around the implementation of CacheManager) or does it mean that it will try and hold onto it forever, thereby polluting the cache space? My gut reaction is that the above is correct because the CacheReloadContext appears to relate to whether or not the relationship between query & resolvedQueryContent has changed, which in this case is guaranteed never to happen. Thanks for you help Alex |