Grails 2.1.1与Terracotta和Ehcache集成

时间:2012-11-30 15:57:08

标签: ehcache terracotta grails-2.1

我试图将Grails 2.1.1与Terracotta和Ehcache整合,但我没有得到任何好的结果。

有人可以给我一些建议吗?我有点困惑。

1 个答案:

答案 0 :(得分:0)

现在在subj上工作。 首先在ehcache.xml目录中创建grails-app/conf。看起来应该是这样的:

<ehcache>                                                                                                                                                                                                                                      

 <terracottaConfig url="vm4:9510"/>                                                                                                                                                                                                           

  <defaultCache                                                                                                                                                                                                                                
      maxElementsInMemory="50"                                                                                                                                                                                                                 
      eternal="false"                                                                                                                                                                                                                          
      timeToIdleSeconds="20"                                                                                                                                                                                                                   
      timeToLiveSeconds="20"                                                                                                                                                                                                                   
      overflowToDisk="false"                                                                                                                                                                                                                   
      diskPersistent="false"                                                                                                                                                                                                                   
      memoryStoreEvictionPolicy="LRU"                                                                                                                                                                                                          
       />                                                                                                                                                                                                                                       

   <cache name="processedUrlCache"                                                                                                                                                                                                              
         maxElementsInMemory="50000"                                                                                                                                                                                                           
         eternal="true">                                                                                                                                                                                                                       
      <terracotta />                                                                                                                                                                                                                             
   </cache>                                                                                                                                                                                                                                     

</ehcache> 

请考虑terracottaConfig网址应指向您的实际主机:Terracotta server所在的端口。确保您的tarracotta缓存节点具有<terracotta/>子节点(类似于我的processUrlCache条目)。

现在,将这3个罐放入项目的lib目录中: ehcache-core-ee-2.6.2.jarehcache-terracotta-ee-2.6.2.jarterracotta-toolkit-1.6-runtime-ee-5.2.0.jar

实际版本可能有所不同(但它应该与terracotta服务器上的版本完全相同,所以我的建议是从服务器lib目录中获取这些jar。)

现在,根据Unix / Windows平台运行您的服务器(start-tc-server.shstart-tc-server.bat)并运行您的grails应用程序。首次启动时,我建议您通过添加

在Config.groovy文件中启用调试日志
debug 'net.sf.ehcache'

进入log4j部分。

让我知道它会对你有所帮助。