Setting up OSCache as the Cache Provider

The facade for OSCache should be an instance of org.wanghy.cache.provider.oscache.OscacheFacade.

Properties:

  1. cacheManager (required).

    Should be an instance of com.opensymphony.oscache.general.GeneralCacheAdministrator.

    We can also use the factory org.wanghy.cache.provider.oscache.OscacheManagerFactoryBean

    Properties:

    1. configLocation (optional).

      Sets the location of the OSCache configuration file.

      The default location is "oscache.properties" in the root of the class path.

  2. cacheProfiles (required).

    Each cache profile should be an instance of org.wanghy.cache.provider.oscache.OscacheCacheProfile.

    Properties:

    1. cronExpression (optional).

      A cron expression that the age of the cache entry will be compared to.

    2. groups (optional).

      The group or groups a cache entry belongs to.

    3. 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.oscache.OscacheManagerFactoryBean">
</bean>

<bean id="cacheProvider"
    class="org.wanghy.cache.provider.oscache.OscacheFacade">
    <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.oscache.OscacheCacheProfile">
                    <property name="refreshPeriod">
                        <value>4</value>
                    </property>
                    <property name="groups">
                        <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.oscache.OscacheManagerFactoryBean">
</bean>

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

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