@ Override public boolean release ( FileCacheable ncfile ) throws IOException { if ( ncfile == null ) return false ; if ( disabled . get ( ) ) { ncfile . setFileCache ( null ) ; // prevent infinite loops ncfile . close ( ) ; return false ; } // find it in the file cache CacheElement . CacheFile file = files . get ( ncfile ) ; // using hashCode of the FileCacheable if ( file != null ) { if ( ! file . isLocked . get ( ) ) { cacheLog . warn ( "FileCache " + name + " release " + ncfile . getLocation ( ) + " not locked; hash= " + ncfile . hashCode ( ) ) ; } file . lastAccessed = System . currentTimeMillis ( ) ; file . countAccessed ++ ; file . isLocked . set ( false ) ; file . ncfile . release ( ) ; if ( cacheLog . isDebugEnabled ( ) ) cacheLog . debug ( "FileCache " + name + " release " + ncfile . getLocation ( ) + "; hash= " + ncfile . hashCode ( ) ) ; if ( debugPrint ) System . out . printf ( " FileCache %s release %s lock=%s count=%d%n" , name , ncfile . getLocation ( ) , file . isLocked . get ( ) , countLocked ( ) ) ; return true ; } return false ; // throw new IOException("FileCache " + name + " release does not have file in cache = " + ncfile.getLocation()); }
Release the file . This unlocks it updates its lastAccessed date . Normally applications need not call this just close the file as usual . The FileCacheable has to do tricky stuff .