chintan4181
2013-04-19 18:59:51 UTC
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.
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.