There are three basic steps to using cache in the spring environment:
1. Configure the ehcache.xml and put it in your resources folder
EHCache Config
2. Put the required spring configuration, injecting the cache in the required bean
Spring Cache Config
3. Use the cache in the bean as you deem fit:
The multiple write, single read bean that uses caching
A helper bean that stores data being passed around
And, of course, you would need the ehcache and spring cache dependencies if you are using maven:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>1.5.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>spring-cache</groupId>
<artifactId>spring-cache</artifactId>
<version>2.4.1</version>
</dependency>
No comments:
Post a Comment