Dashboard > OSCache > ... > Documentation > Spring
  OSCache Log In View a printable version of the current page.  
  Spring
Added by Lars Torunski, last edited by Lars Torunski on Apr 22, 2007
Labels: 
(None)

Configuring a GeneralCacheAdministrator

A GeneralCacheAdministrator instance that picks up configuration from an oscache.properties file can be configured within Spring using the following code:

<bean id="cacheAdministrator" class="com.opensymphony.oscache.general.GeneralCacheAdministrator" destroy-method="destroy"/>

Notice that a destory-method is configured to ensure that the GeneralCacheAdministrator is closed down gracefully.

If you'd prefer to keep all your configuration inside the Spring configuration, you can omit the oscache.properties file and pass in any properties you want to the GeneralCacheAdministrator constructor like so:

<bean id="cacheAdministrator" class="com.opensymphony.oscache.general.GeneralCacheAdministrator" destroy-method="destroy">
    <constructor-arg index="0">
        <props>
            <prop key="cache.memory">true</prop>
        </props>
    </constructor-arg>
</bean>

Configuring a Cache

You can configure a Cache instance directly using the following snippet of code:

<bean id="cache" class="com.opensymphony.oscache.base.Cache">
    <constructor-arg index="0">
        <value>true</value> <!-- useMemoryCaching -->
    <constructor-arg>
    <constructor-arg index="1">
        <value>true</value> <!-- unlimitedDiskCache -->
    <constructor-arg>
    <constructor-arg index="2">
        <value>true</value> <!-- overflowPersistence -->
    <constructor-arg>
</bean>

Alternatively, you can pick up the Cache from the GeneralCacheAdministrator like so:

<bean id="cacheAdministrator" class="com.opensymphony.oscache.general.GeneralCacheAdministrator" destroy-method="destroy"/>

<bean id="cache" factory-bean="cacheAdministrator" factory-method="getCache"/>

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request - Contact Administrators