コード例 #1
0
ファイル: UtilCache.java プロジェクト: CrasOu/haze
 /** This is used for internal remove calls because we only want to count external calls */
 @SuppressWarnings("unchecked")
 protected synchronized V removeInternal(Object key, boolean countRemove) {
   if (key == null) {
     if (Debug.verboseOn())
       Debug.logVerbose(
           "In UtilCache tried to remove with null key, using NullObject" + this.name, module);
   }
   Object nulledKey = fromKey(key);
   CacheLine<V> oldCacheLine;
   V oldValue;
   if (fileTable != null) {
     try {
       synchronized (this) {
         try {
           oldValue = fileTable.get(nulledKey);
         } catch (IOException e) {
           oldValue = null;
           throw e;
         }
         fileTable.remove(nulledKey);
         jdbmMgr.commit();
       }
     } catch (IOException e) {
       oldValue = null;
       Debug.logError(e, module);
     }
     oldCacheLine = memoryTable.remove(nulledKey);
   } else {
     oldCacheLine = memoryTable.remove(nulledKey);
     oldValue = oldCacheLine != null ? oldCacheLine.getValue() : null;
   }
   if (oldCacheLine != null) {
     cancel(oldCacheLine);
   }
   if (oldValue != null) {
     noteRemoval((K) key, oldValue);
     if (countRemove) removeHitCount.incrementAndGet();
     return oldValue;
   } else {
     if (countRemove) removeMissCount.incrementAndGet();
     return null;
   }
 }