Template Caching doesn't work

chintan4181 <[email protected]> Fri, 19 Apr 2013 11:59:51 -0700 (PDT)
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Hi, 

I am using Freemarker for email template with spring. I want to cache my
template, but somehow it's not working. Below is my configuration 

Spring configuration:
 <bean id="freemarkerMailConfiguration"
class="org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean">
   		<property name="freemarkerSettings">
   			 <props>
   			 	<prop key="cache_storage">strong:50, soft:500</prop>
   			 	<prop key="template_update_delay">40</prop>
   			 </props>
   		</property>
   </bean>

private String getContent(String templateFileName, String templatedir,
java.util.Map<String, Object> dynamicParams) throws Exception {
		if(ftl == null)
			ftl = new FileTemplateLoader(new File(templatedir));		
		
		configuration.setTemplateLoader(ftl); //configuration object is injected
by spring which has   //MruStorage cache with 50,500

		template = configuration.getTemplate(templateFileName); //all the time
parse same template again.
		String result =
FreeMarkerTemplateUtils.processTemplateIntoString(template, dynamicParams);
		
		return result;
	}

I am calling getContent method for 3 times before sending email. but all
times it prints below message in the log
Could not find template in cache, creating new one;
id=[mail-template.txt[en_US,Cp1252,parsed] ]
Compiling FreeMarker template mail-template.txt[en_US,Cp1252,parsed]

Can somebody tell me, how do i cache the template so it retrieve from Cache.

Thanks
Chintan



--
View this message in context: http://freemarker.624813.n4.nabble.com/Template-Caching-doesn-t-work-tp4654527.html
Sent from the freemarker-user mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter