something like this for the skeleton
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="cacheManager"
class="
org.springmodules.cache.provider.oscache.OsCacheManagerFactoryBean">
<property name="configLocation">
<value>classpath:oscache.properties</value>
</property>
</bean>
<bean id="cacheProviderFacade"
class="org.springmodules.cache.provider.oscache.OsCacheFacade">
<property name="cacheManager" ref="cacheManager" />
</bean>
<bean id="cacheProxyTemplate" abstract="true"
class="
org.springmodules.cache.interceptor.proxy.CacheProxyFactoryBean">
<property name="cacheProviderFacade">
<ref local="cacheProviderFacade" />
</property>
<property name="cacheKeyGenerator">
<ref local="cacheKeyGenerator" />
</property>
</bean>
<bean id="cacheKeyGenerator"
class="com.xxx.MethodObjectCacheKeyGenerator">
</bean>
<bean id="valueCacheKeyGenerator"
class="com.xxx.ValueCacheKeyGenerator">
</bean>
</beans>
and use it with
<bean id="positionVacancyDAO" parent="cacheProxyTemplate">
<property name="cachingModels">
<props>
<prop key="findCompanies">refreshPeriod=300</prop>
</props>
</property>
<property name="target">
<ref local="positionVacancyDAOTarget" />
</property>
</bean>
where the "positionVacancyDAOTarget" is you dao does the query to the
database
"findCompanies" is function call you want to cache the result
and "refreshPeriod=300" means first call goes to the db, and for every call
within 5 minutes (300 seconds), just use the cache.
i think ideally there is a transaction-proxied service that uses your
cache-proxied dao and your jsf code calls the service.
i've asked the spring people about this, and they hinted that using
hibernate and a secondary cache is better..