cdm/src/main/java/ucar/nc2/util/cache/FileCacheARC.java
private void addToCache(Object hashKey, FileCacheable ncfile) {
    CacheElement newCacheElem = new CacheElement(hashKey);
    CacheElement previous = cache.putIfAbsent(hashKey, newCacheElem); // add new element if doesnt exist
    CacheElement elem = (previous != null) ? previous : newCacheElem;  // use previous if it exists

    elem.addFile(ncfile);                                 // add to existing list
    shadowCache.put(newCacheElem, newCacheElem);

    int size = cacheSize.getAndIncrement();
    if (size > softLimit) {
      removeFromCache(size - softLimit);
    }
  }
private void addToCache(Object hashKey, FileCacheable ncfile) {
    CacheElement newCacheElem = new CacheElement(hashKey);
    CacheElement previous = cache.putIfAbsent(hashKey, newCacheElem); // add new element if doesnt exist
    CacheElement elem = (previous != null) ? previous : newCacheElem;  // use previous if it exists

    elem.addFile(ncfile);                                 // add to existing list
    shadowCache.put(newCacheElem, newCacheElem);

    int size = cacheSize.getAndIncrement();
    if (size > softLimit) {
      removeFromCache(size - softLimit);
    }
  }
private void addToCache ( Object hashKey , FileCacheable ncfile ) { CacheElement newCacheElem = new CacheElement ( hashKey ) ; CacheElement previous = cache . putIfAbsent ( hashKey , newCacheElem ) ; // add new element if doesnt exist CacheElement elem = ( previous != null ) ? previous : newCacheElem ; // use previous if it exists elem . addFile ( ncfile ) ; // add to existing list shadowCache . put ( newCacheElem , newCacheElem ) ; int size = cacheSize . getAndIncrement ( ) ; if ( size > softLimit ) { removeFromCache ( size - softLimit ) ; } }
/*
if (disabled.get()) return;

see if its in the cache
CacheElement wantCacheElem = cache.get(hashKey);
if (wantCacheElem == null) return;

synchronized (wantCacheElem) { // synch in order to traverse the list
for (CacheElement.CacheFile want : wantCacheElem.list) {
files.remove(want.ncfile);
want.ncfile.setFileCache(null); // unhook the caching
try {
want.ncfile.close();  // really close the file
log.debug("close "+want.ncfile.getLocation());
} catch (IOException e) {
log.error("close failed on "+want.ncfile.getLocation(), e);
}
want.ncfile = null;
}
wantCacheElem.list.clear();
}
cache.remove(hashKey);
}
/ * if ( disabled . get () ) return ;