eboix
Feb 10th, 2006, 07:13 AM
Hi all,
I'm using the OSCache integration from SprindModules, and it really improves the performance of the app, but I can't get the cache to flush.
Here goes an excerpt of the config:
<bean id="baseDao" class="org.springmodules.cache.interceptor.proxy.CachePro xyFactoryBean">
<property name="cacheProviderFacade">
<ref local="cacheProvider" />
</property>
<property name="cachingAttributes">
<props>
<prop key="obtenirTotesFasesProduccio">[cacheProfileId=cacheWheels]</prop>
</props>
</property>
<property name="cacheFlushAttributes">
<props>
<prop key="actualitzarFase">[cacheProfileIds=cacheWheels][flushBeforeExecution=true]</prop>
</props>
</property>
<property name="target">
<ref bean="baseDaoTarget"/>
</property>
</bean>
...the idea is to cache results from "obtenirTotesFasesProduccio", and flush before executing "actualitzarFase" in "baseDaoTarget".
I've enable debugging:
The first call gets cached:
2006-02-10 12:58:43,818 DEBUG [org.springframework.transaction.support.Transactio nSynchronizationManager] - Initializing transaction synchronization
2006-02-10 12:58:43,818 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getFromCache(CacheKey, String)'. Argument 'cacheKey': 629|22072380
2006-02-10 12:58:43,818 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getCacheProfile(String)'. Argument 'cacheProfileId': cacheWheels
2006-02-10 12:58:43,818 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getCacheProfile(String)'. Variable 'cacheProfile': org.springmodules.cache.provider.oscache.OsCachePr ofile@190b03c[refreshPeriod=<null>,groups=<null>,cronExpression=<null>]
2006-02-10 12:58:43,818 DEBUG [com.opensymphony.oscache.base.algorithm.AbstractCo ncurrentReadCache] - get called (key=629|22072380)
2006-02-10 12:58:43,818 DEBUG [com.opensymphony.oscache.base.algorithm.AbstractCo ncurrentReadCache] - persistRetrieve called (key=629|22072380)
2006-02-10 12:58:43,818 DEBUG [com.opensymphony.oscache.base.Cache] - No cache entry exists for key='629|22072380', creating
2006-02-10 12:58:43,819 DEBUG [org.springmodules.cache.provider.oscache.OsCacheFa cade] - Method 'getFromCache(..)'. Object not found in the OSCache cache
2006-02-10 12:58:43,819 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getFromCache(CacheKey, String)'. Variable 'cachedObject': null
Later, a call to "actualitzarFase" generates the following log (so the cache seems to be cleared):
2006-02-10 12:58:50,031 DEBUG [org.springframework.transaction.support.Transactio nSynchronizationManager] - Initializing transaction synchronization
2006-02-10 12:58:50,031 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'flushCache(String[])'. Argument 'cacheProfileIds': {cacheWheels}
2006-02-10 12:58:50,031 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getCacheProfile(String)'. Argument 'cacheProfileId': cacheWheels
2006-02-10 12:58:50,031 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getCacheProfile(String)'. Variable 'cacheProfile': org.springmodules.cache.provider.oscache.OsCachePr ofile@190b03c[refreshPeriod=<null>,groups=<null>,cronExpression=<null>]
2006-02-10 12:58:50,031 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'flushCache(String[])'. Cache flushed.
2006-02-10 12:58:50,032 INFO [project.Dao.BaseDao] - Actualitzant la fase Calidad! per empresa 1
2006-02-10 12:58:50,032 DEBUG [org.springframework.jdbc.core.JdbcTemplate] - Executing SQL update [ update hmFaseProduccion set hFaseProduccion=?, hOrdenEnProceso=? where CodigoEmpresa=? and hCodigoFaseProduccion=?]
But a later call to "obtenirFasesProduccio" gets again the first cached value from the cache:
2006-02-10 12:58:50,125 DEBUG [org.springframework.transaction.support.Transactio nSynchronizationManager] - Initializing transaction synchronization
2006-02-10 12:58:50,125 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getFromCache(CacheKey, String)'. Argument 'cacheKey': 629|22072380
2006-02-10 12:58:50,125 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getCacheProfile(String)'. Argument 'cacheProfileId': cacheWheels
2006-02-10 12:58:50,125 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getCacheProfile(String)'. Variable 'cacheProfile': org.springmodules.cache.provider.oscache.OsCachePr ofile@190b03c[refreshPeriod=<null>,groups=<null>,cronExpression=<null>]
2006-02-10 12:58:50,126 DEBUG [com.opensymphony.oscache.base.algorithm.AbstractCo ncurrentReadCache] - get called (key=629|22072380)
2006-02-10 12:58:50,126 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getFromCache(CacheKey, String)'. Variable 'cachedObject': [project.Beans.Fase@1b5c3de, project.Beans.Fase@4e6138, project.Beans.Fase@1d0c37d, project.Beans.Fase@d2499a, project.Beans.Fase@1de3994, project.Beans.Fase@9637fe]
2006-02-10 12:58:50,126 DEBUG [org.springframework.transaction.interceptor.Transa ctionInterceptor] - Invoking commit for transaction on project.Logica.IMantenimentAppBl.obtenirFases
Anyone is using OSCache with Spring ? Maybe I should try another cache impl ?
Regards,
Esteve
I'm using the OSCache integration from SprindModules, and it really improves the performance of the app, but I can't get the cache to flush.
Here goes an excerpt of the config:
<bean id="baseDao" class="org.springmodules.cache.interceptor.proxy.CachePro xyFactoryBean">
<property name="cacheProviderFacade">
<ref local="cacheProvider" />
</property>
<property name="cachingAttributes">
<props>
<prop key="obtenirTotesFasesProduccio">[cacheProfileId=cacheWheels]</prop>
</props>
</property>
<property name="cacheFlushAttributes">
<props>
<prop key="actualitzarFase">[cacheProfileIds=cacheWheels][flushBeforeExecution=true]</prop>
</props>
</property>
<property name="target">
<ref bean="baseDaoTarget"/>
</property>
</bean>
...the idea is to cache results from "obtenirTotesFasesProduccio", and flush before executing "actualitzarFase" in "baseDaoTarget".
I've enable debugging:
The first call gets cached:
2006-02-10 12:58:43,818 DEBUG [org.springframework.transaction.support.Transactio nSynchronizationManager] - Initializing transaction synchronization
2006-02-10 12:58:43,818 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getFromCache(CacheKey, String)'. Argument 'cacheKey': 629|22072380
2006-02-10 12:58:43,818 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getCacheProfile(String)'. Argument 'cacheProfileId': cacheWheels
2006-02-10 12:58:43,818 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getCacheProfile(String)'. Variable 'cacheProfile': org.springmodules.cache.provider.oscache.OsCachePr ofile@190b03c[refreshPeriod=<null>,groups=<null>,cronExpression=<null>]
2006-02-10 12:58:43,818 DEBUG [com.opensymphony.oscache.base.algorithm.AbstractCo ncurrentReadCache] - get called (key=629|22072380)
2006-02-10 12:58:43,818 DEBUG [com.opensymphony.oscache.base.algorithm.AbstractCo ncurrentReadCache] - persistRetrieve called (key=629|22072380)
2006-02-10 12:58:43,818 DEBUG [com.opensymphony.oscache.base.Cache] - No cache entry exists for key='629|22072380', creating
2006-02-10 12:58:43,819 DEBUG [org.springmodules.cache.provider.oscache.OsCacheFa cade] - Method 'getFromCache(..)'. Object not found in the OSCache cache
2006-02-10 12:58:43,819 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getFromCache(CacheKey, String)'. Variable 'cachedObject': null
Later, a call to "actualitzarFase" generates the following log (so the cache seems to be cleared):
2006-02-10 12:58:50,031 DEBUG [org.springframework.transaction.support.Transactio nSynchronizationManager] - Initializing transaction synchronization
2006-02-10 12:58:50,031 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'flushCache(String[])'. Argument 'cacheProfileIds': {cacheWheels}
2006-02-10 12:58:50,031 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getCacheProfile(String)'. Argument 'cacheProfileId': cacheWheels
2006-02-10 12:58:50,031 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getCacheProfile(String)'. Variable 'cacheProfile': org.springmodules.cache.provider.oscache.OsCachePr ofile@190b03c[refreshPeriod=<null>,groups=<null>,cronExpression=<null>]
2006-02-10 12:58:50,031 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'flushCache(String[])'. Cache flushed.
2006-02-10 12:58:50,032 INFO [project.Dao.BaseDao] - Actualitzant la fase Calidad! per empresa 1
2006-02-10 12:58:50,032 DEBUG [org.springframework.jdbc.core.JdbcTemplate] - Executing SQL update [ update hmFaseProduccion set hFaseProduccion=?, hOrdenEnProceso=? where CodigoEmpresa=? and hCodigoFaseProduccion=?]
But a later call to "obtenirFasesProduccio" gets again the first cached value from the cache:
2006-02-10 12:58:50,125 DEBUG [org.springframework.transaction.support.Transactio nSynchronizationManager] - Initializing transaction synchronization
2006-02-10 12:58:50,125 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getFromCache(CacheKey, String)'. Argument 'cacheKey': 629|22072380
2006-02-10 12:58:50,125 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getCacheProfile(String)'. Argument 'cacheProfileId': cacheWheels
2006-02-10 12:58:50,125 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getCacheProfile(String)'. Variable 'cacheProfile': org.springmodules.cache.provider.oscache.OsCachePr ofile@190b03c[refreshPeriod=<null>,groups=<null>,cronExpression=<null>]
2006-02-10 12:58:50,126 DEBUG [com.opensymphony.oscache.base.algorithm.AbstractCo ncurrentReadCache] - get called (key=629|22072380)
2006-02-10 12:58:50,126 DEBUG [org.springmodules.cache.provider.AbstractCacheProv iderFacadeImpl] - Method 'getFromCache(CacheKey, String)'. Variable 'cachedObject': [project.Beans.Fase@1b5c3de, project.Beans.Fase@4e6138, project.Beans.Fase@1d0c37d, project.Beans.Fase@d2499a, project.Beans.Fase@1de3994, project.Beans.Fase@9637fe]
2006-02-10 12:58:50,126 DEBUG [org.springframework.transaction.interceptor.Transa ctionInterceptor] - Invoking commit for transaction on project.Logica.IMantenimentAppBl.obtenirFases
Anyone is using OSCache with Spring ? Maybe I should try another cache impl ?
Regards,
Esteve