Removing templates manually from a cache.
Frank Zeyda <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Dear FreeMarker Developers, Here's a small problem I encountered when using a MultiTemplateLoader that first loads templates from the file store, and via a second StringTemplateLoader allows for creation and use of on-the-fly templates while the program executes. The reason for using a common loader is intentional so that the on-the-fly templates can include those from the file store where needed. My problem is that I reuse the same name for the on-the-fly templates when inserting them i.e. using the StringTemplateLoader method (putTemplate(...)). This does not seem to cause the template to be reloaded unless one clears the entire cache using clearTemplateCache() of the TemplateCache object. This, however, appears to be inefficient as I suppose it would cause all templates previously cached to be reloaded. setDelay() is not much use since I need the one template to be reloaded immediately. To solve the problem, I tried to create and set my own CacheStore, however, the methods get(...), put(...) and remove(...) are of not much use here since one has no public access to the object that is used as the key in the underlying map (TemplateCache.TemplateKey is private). So, to summarise, the solution to the above problem via clearTemplateCache() seems to be not entirely satisfactory. Instead one may wish to have finer control about the caches, for instance, in order to remove specific entries manually; possibly via a method in TemplateCache, or by way of exposing TemplateCache.TemplateKey so that keys can be created by the user. Many thanks for any comments, in particular in case I am missing a simpler solution. Best wishes Frank ------------------------------------------------------------------------------ 10 Tips for Better Server Consolidation Server virtualization is being driven by many needs. But none more important than the need to reduce IT complexity while improving strategic productivity. Learn More! http://www.accelacomm.com/jaw/sdnl/114/51507609/