Setting up LRU Cache as the Cache Provider

The facade for LRU Cache should be an instance of org.wanghy.cache.provider.lru.LruCacheFacade.

Properties:

  1. cacheManager (required).

    Should be an implementation of the interface org.wanghy.cache.provider.lru.LruCacheManager. The default implementation is org.wanghy.cache.provider.lru.LruMapCacheManager. We can also use the factory org.wanghy.cache.provider.lru.LruCacheManagerFactoryBean

    Properties:

    1. maxSize (optional).

      The maximum capacity of the cache manager. Should be greater than one.

      The default maximum capacity is LruMapCacheManager.DEFAULT_MAX_SIZE.

    2. scanUntilRemovable (optional).

      Indicates if the cache manager should scan until a removeable entry is found. The default value is false.

  2. cacheProfiles (required).

    Each cache profile should be an instance of org.wanghy.cache.provider.lru.LruCacheProfile

    Properties:

    1. group (required).

      The group a cache entry belongs to.

    2. refreshPeriod (optional).

      How long an entry can stay in cache (in seconds).

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.wanghy.cache.provider.lru.LruCacheManagerFactoryBean">
</bean>

<bean id="cacheProvider"
    class="org.wanghy.cache.provider.lru.LruCacheFacade">
    <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.lru.LruCacheProfile">
                    <property name="group">
                        <value>testGroup</value>
                    </property>
                </bean>
            </entry>
        </map>
    </property>
</bean>

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

<bean id="cacheManager"
    class="org.wanghy.cache.provider.lru.LruCacheManagerFactoryBean">
</bean>

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

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