oscache 死锁

用value为null的key连续两次调用getFromCache时,如果不向cache中放入value,且不调用cancelUpdate,则会发生死锁。

try {

                    Object obj= oscache.getFromCache(key, commentRefreshPeriod);

                } catch (NeedsRefreshException e) {

//如果不能putInCache

                    oscache.cancelUpdate(key);

                }

   /**

     * Cancels a pending cache update. This should only be called by a thread

     * that received a {@link NeedsRefreshException} and was unable to generate

     * some new cache content.

     *

     * @param key The cache entry key to cancel the update of.

     */

    public void cancelUpdate(String key) {

        getCache().cancelUpdate(key);

    }

参考:

http://markmail.org/message/xzff2x4uw6ka37p3#query:oscache%20deadlock+page:1+mid:v4uq5vl76b5u6p76+state:results

猜你喜欢

转载自darktemplar-h.iteye.com/blog/1156950
今日推荐