ucar.nc2.util.cache
Class FileCacheRaf

java.lang.Object
  extended by ucar.nc2.util.cache.FileCacheRaf

public class FileCacheRaf
extends Object

Keep cache of open RandomAccessFile, for performance. Used by TDS to optimize serving netCDF files over HTTP.

 RandomAccessFile raf = null;
 try {
 RandomAccessFile raf = FileCache.acquire(location, cancelTask);
 ...
 } finally {
 FileCache.release( raf)
 }
 

Library ships with cache disabled. If you want to use, call init() and make sure you call exit() when exiting program. All methods are thread safe. Cleanup is done automatically in a background thread, using LRU.

Author:
jcaron

Nested Class Summary
 class FileCacheRaf.Raf
           
 
Constructor Summary
FileCacheRaf(int minElementsInMemory, int maxElementsInMemory, int period)
           
 
Method Summary
 FileCacheRaf.Raf acquire(String filename)
           
 void clearCache(boolean force)
           
 Collection getCache()
           
 void release(FileCacheRaf.Raf craf)
           
static void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileCacheRaf

public FileCacheRaf(int minElementsInMemory,
                    int maxElementsInMemory,
                    int period)
Method Detail

clearCache

public void clearCache(boolean force)

getCache

public Collection getCache()

shutdown

public static void shutdown()

acquire

public FileCacheRaf.Raf acquire(String filename)
                         throws IOException
Throws:
IOException

release

public void release(FileCacheRaf.Raf craf)
             throws IOException
Throws:
IOException


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.