cdm/src/main/java/ucar/nc2/util/cache/FileCacheARC.java
private FileCacheable acquireCacheOnly(Object hashKey) {
    if (disabled.get()) return null;

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

    CacheElement.CacheFile want = null;
    for (CacheElement.CacheFile file : wantCacheElem.list) {
      if (file.isLocked.compareAndSet(false, true)) {
        want = file;
        break;
      }
    }
    if (want == null) return null; // no unlocked file in cache

    // check if modified, remove if so
    if (want.ncfile != null) {
      long lastModified = want.ncfile.getLastModified();
      boolean changed = lastModified != wantCacheElem.lastModified.get();

      if (changed) { // underlying file was modified
        if (cacheLog.isDebugEnabled())
          cacheLog.debug("FileCacheARC " + name + ": acquire from cache " + hashKey + " " + want.ncfile.getLocation() + " was changed; discard");

        expireFromCache(wantCacheElem);
        return null;
      }
    }

    updateInCache(wantCacheElem);
    return want.ncfile;
  }
private FileCacheable acquireCacheOnly(Object hashKey) {
    if (disabled.get()) return null;

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

    CacheElement.CacheFile want = null;
    for (CacheElement.CacheFile file : wantCacheElem.list) {
      if (file.isLocked.compareAndSet(false, true)) {
        want = file;
        break;
      }
    }
    if (want == null) return null; // no unlocked file in cache

    // check if modified, remove if so
    if (want.ncfile != null) {
      long lastModified = want.ncfile.getLastModified();
      boolean changed = lastModified != wantCacheElem.lastModified.get();

      if (changed) { // underlying file was modified
        if (cacheLog.isDebugEnabled())
          cacheLog.debug("FileCacheARC " + name + ": acquire from cache " + hashKey + " " + want.ncfile.getLocation() + " was changed; discard");

        expireFromCache(wantCacheElem);
        return null;
      }
    }

    updateInCache(wantCacheElem);
    return want.ncfile;
  }
private FileCacheable acquireCacheOnly ( Object hashKey ) { if ( disabled . get ( ) ) return null ; // see if its in the cache CacheElement wantCacheElem = cache . get ( hashKey ) ; if ( wantCacheElem == null ) return null ; // not found in cache CacheElement . CacheFile want = null ; for ( CacheElement . CacheFile file : wantCacheElem . list ) { if ( file . isLocked . compareAndSet ( false , true ) ) { want = file ; break ; } } if ( want == null ) return null ; // no unlocked file in cache // check if modified, remove if so if ( want . ncfile != null ) { long lastModified = want . ncfile . getLastModified ( ) ; boolean changed = lastModified != wantCacheElem . lastModified . get ( ) ; if ( changed ) { // underlying file was modified if ( cacheLog . isDebugEnabled ( ) ) cacheLog . debug ( "FileCacheARC " + name + ": acquire from cache " + hashKey + " " + want . ncfile . getLocation ( ) + " was changed; discard" ) ; expireFromCache ( wantCacheElem ) ; return null ; } } updateInCache ( wantCacheElem ) ; return want . ncfile ; }
Try to find a file in the cache.

@param hashKey used as the key.
@return file if its in the cache, null otherwise.
Try to find a file in the cache .