spring-mvcehcachemybatis

What is the best way to cache static data lookups with Spring 3.1, Mybatis 3 and ehcache?


I followed the recommendation on mybatis-ecache integration but I don't see any log statements from EhCacheCache.

Spring also has an eh-cache integration, which at first glance looks simple to implement but I haven't seen it being fired in the logs either.

Ideally I'd like to setup the cache before the Rest call itself to save the roundtri[p to the backend webservice (which calls mybatis mappers). Is there a working example, a preferred approach with Spring ehCache over mybatis ehCache?


Solution

  • Our app uses to wars: webservices, ui. I cached the mybatis dataaccess in webservices layer using mybatis-cache, and added a spring-ehcache on the ui layer. That way the mybatis-cache acts as a first-level cache, reusuable for any other service, and spring-ehcache acts as a second level cachce for the front end.