public class Cache
extends java.util.LinkedHashMap<java.lang.String,java.io.File>
implements java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
static long |
DELETE_CACHE |
static long |
GET_CACHE |
| Constructor and Description |
|---|
Cache(int cacheSize,
long maxBytes) |
| Modifier and Type | Method and Description |
|---|---|
void |
addDocToCache(gov.noaa.pmel.tmap.jdom.LASDocument doc,
java.lang.String cacheFileName) |
void |
addFile(java.lang.String query,
java.io.File file)
Add a file to the cache if the cache object is enabled.
|
void |
addToCache(LASBackendResponse lasResponse,
java.lang.String cacheFileName) |
boolean |
cacheHit(LASBackendResponse lasResponse) |
void |
clean()
Delete all the files in this cache object
|
int |
getCacheSize() |
long |
getCurrentBytes() |
java.io.File |
getFile(java.lang.String query,
long time)
Get the file identified by a string if the cache object is enabled.
|
java.util.ArrayList<java.lang.String> |
getFiles(java.lang.String key)
Get all the files form the cache that are associated with a particular (compound response) key.
|
long |
getMaxBytes() |
boolean |
isEnabled()
Test if this cache object is enabled
|
void |
loadCacheFromStore(java.io.File cacheFile)
Load a local file and populate this cache object
|
void |
removeFile(java.lang.String filename) |
void |
saveCacheToStore(java.io.File cacheFile)
Serialize this cache object to a local file
|
void |
setCacheSize(int cacheSize) |
void |
setCurrentBytes(long currentBytes) |
void |
setEnabled(boolean enabled)
Enable or disable this cache object according to
the input parameter
|
void |
setMaxBytes(long maxBytes) |
public boolean isEnabled()
public void setEnabled(boolean enabled)
enabled - specified if this cache object should be enabled or disabled.public void addFile(java.lang.String query,
java.io.File file)
query - a string that is the key to the file. The file
can be retrieved using this string.file - the File object that need to be stored in cache.public java.io.File getFile(java.lang.String query,
long time)
query - a string that is the key to the file. The file
can be retrieved using this string.time - only a file newer than this time should be returned.
If this parameter is equal to Cache.DELETE_CACHE, cache
file will be deleted and return null. If this parameter is equal to
Cache.GET_CACHE, cache file will always be returned if it
exists.public void removeFile(java.lang.String filename)
public void clean()
public void saveCacheToStore(java.io.File cacheFile)
throws gov.noaa.pmel.tmap.exception.LASException
cacheFile - the local file to store this cache objectgov.noaa.pmel.tmap.exception.LASExceptionpublic void loadCacheFromStore(java.io.File cacheFile)
throws gov.noaa.pmel.tmap.exception.LASException
cacheFile - the local file to loadgov.noaa.pmel.tmap.exception.LASExceptionpublic boolean cacheHit(LASBackendResponse lasResponse)
public void addToCache(LASBackendResponse lasResponse, java.lang.String cacheFileName)
public void addDocToCache(gov.noaa.pmel.tmap.jdom.LASDocument doc,
java.lang.String cacheFileName)
public long getMaxBytes()
public int getCacheSize()
public void setMaxBytes(long maxBytes)
maxBytes - the maxBytes to setpublic void setCacheSize(int cacheSize)
cacheSize - the cacheSize to setpublic java.util.ArrayList<java.lang.String> getFiles(java.lang.String key)
key - public long getCurrentBytes()
public void setCurrentBytes(long currentBytes)
currentBytes - the currentBytes to set