|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectucar.unidata.io.FileCache
public class FileCache
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.
| Nested Class Summary | |
|---|---|
static class |
FileCache.CacheElement
This tracks the elements in the cache. |
| Constructor Summary | |
|---|---|
FileCache()
|
|
| Method Summary | |
|---|---|
static RandomAccessFile |
acquire(java.lang.String location)
|
static RandomAccessFile |
acquireCacheOnly(java.lang.String location)
Try to find a file in the cache. |
static void |
clearCache(boolean force)
|
static void |
disable()
Disable use of the cache. |
static void |
exit()
You must call exit() to shut down the background timer in order to get a clean process shutdpwn. |
static java.util.List |
getCache()
Get the files in the cache. |
static void |
init()
Default 10 minimum, 20 maximum files, cleanup every 20 minutes |
static void |
init(int minElementsInMemory,
int maxElementsInMemory,
long period)
Initialize the cache. |
static void |
release(RandomAccessFile raf)
Release the file. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileCache()
| Method Detail |
|---|
public static void init()
public static void init(int minElementsInMemory,
int maxElementsInMemory,
long period)
minElementsInMemory - keep this number in the cachemaxElementsInMemory - trigger a cleanup if it goes over this number.period - (secs) do periodic cleanups every this number of seconds.public static void disable()
public static void exit()
public static RandomAccessFile acquireCacheOnly(java.lang.String location)
location - file location is used as the key.
public static RandomAccessFile acquire(java.lang.String location)
throws java.io.IOException
java.io.IOException
public static void release(RandomAccessFile raf)
throws java.io.IOException
raf - release this file.
java.io.IOException - if file not in cache.public static java.util.List getCache()
public static void clearCache(boolean force)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||