O'Reilly logo

Mastering Spring Application Development by Anjana Mankale

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Spring caching repository

The cache repository is where the actual objects are saved. Spring supports two types of repositories:

Using ConcurrentMap is also an option for implementing caching in the application. The repository has little (if any) effect on the code, and switching between repositories should be very easy. Our objects will be cached within a ConcurrentMap.

We can configure the ConcurrentMap as shown in the following code:

  <bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
    <property name="caches">
     <set>
       <bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="task" />
     </set>
    </property>
       </bean>

The Ehcache popular library

This cache is used by a lot of popular frameworks ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required