osCache的问题,不解中

今天在使用spring-cache和osCache时发现了一个问题,当缓存目标方法发生异常时,会死锁。就是updateState.wait();造成的。在此做个标记,以后研究。目前使用EHCache就没有类似的问题发生
com.opensymphony.oscache.base.Cache#getFromCache

// Another thread is already updating the cache. We block if this
// is a new entry, or blocking mode is enabled. Either putInCache()
// or cancelUpdate() can cause this thread to resume.
if (cacheEntry.isNew() || blocking) {
do {
try {
updateState.wait();
} catch (InterruptedException e) {
}
} while (updateState.isUpdating());

if (updateState.isCancelled()) {
// The updating thread cancelled the update, let this one have a go.
// This increments the usage count for this EntryUpdateState instance
updateState.startUpdate();

if (cacheEntry.isNew()) {
accessEventType = CacheMapAccessEventType.MISS;
} else {
accessEventType = CacheMapAccessEventType.STALE_HIT;
}
} else if (updateState.isComplete()) {
reload = true;
} else {
log.error("Invalid update state for cache entry " + key);
}
}

附上使用EHCache基于AOP方式的缓存配置文件,权当日记吧,算不上总结。

<!-- EHCache AOP -->
<bean id="eHCacheInterceptor"
class="org.springframework.aop.interceptor.cache.EHCacheInterceptor" scope="singleton">
<property name="refreshPeriods">
<value>600</value>
</property>
<property name="defaultRefreshPeriod">
<value>900</value>
</property>
<property name="identifiers">
<props>
<prop key="java.util.Map">toString</prop>
</props>
</property>
</bean>
<bean id="eHCacheAdvisor"
class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice">
<ref bean="eHCacheInterceptor" />
</property>
<property name="patterns">
<list>
<value>.*search.*</value>
<value>.*get.*</value>
<value>.*find.*</value>
</list>
</property>
</bean>
<bean id="eHCacheProxyCreator"
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<value>*Service</value>
</property>
<property name="interceptorNames">
<list>
<value>eHCacheAdvisor</value>
</list>
</property>
<property name="proxyTargetClass">
<value>true</value>
</property>
</bean>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值