Setting up EHCache as the Cache Provider

The facade for EHCache should be an instance of org.wanghy.cache.provider.ehcache.EhcacheFacade.

Properties:

  1. cacheManager (required).

    Should be an instance of net.sf.ehcache.CacheManager.

    We can also use the factory org.springframework.cache.ehcache.EhCacheManagerFactoryBean.

  2. cacheProfiles (required).

    Each cache profile should be an instance of org.wanghy.cache.provider.ehcache.EhcacheCacheProfile

    Properties:

    1. cacheName (required).

      The name of the cache used to store/retrieve an object.

For general information about setting up the cache provider please read "Setting up the Cache Provider".

Examples

The cache profiles are defined as a java.util.Map:

<bean id="cacheManager"
    class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
</bean>

<bean id="cacheProvider"
    class="org.wanghy.cache.provider.ehcache.EhcacheFacade">
    <property name="cacheManager">
        <ref local="cacheManager" />
    </property>

    <!-- Cache profiles specified as a java.util.Map -->
    <property name="cacheProfiles">
        <map>
            <entry key="test">
                <bean class="org.wanghy.cache.provider.ehcache.EhcacheCacheProfile">
                    <property name="cacheName">
                        <value>testCache</value>
                    </property>
                </bean>
            </entry>
        </map>
    </property>
</bean>

The cache profiles are defined as a java.util.Properties:

<bean id="cacheManager"
    class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
</bean>

<bean id="cacheProvider"
    class="org.wanghy.cache.provider.ehcache.EhcacheFacade">
    <property name="cacheManager">
        <ref local="cacheManager" />
    </property>

    <!-- Cache profiles specified as a java.util.Properties -->
    <property name="cacheProfiles">
        <props>
            <prop key="test">[cacheName=testCache]</prop>
        </props>
    </property>
</bean>