|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectucar.nc2.util.DiskCache2
public class DiskCache2
Manages a place on disk to persistently cache files, which are deleted when the last modified date exceeds a certain time. This starts up a thread to periodically scour itself; be sure to call exit() to terminate the thread.
Each DiskCache has a "root directory", which may be set as an absolute path, or reletive to the DiskCache "home directory". The root directory must be writeable. The DiskCache home directory is set in the following order:
| Field Summary | |
|---|---|
static int |
CACHEPATH_POLICY_NESTED_DIRECTORY
|
static int |
CACHEPATH_POLICY_NESTED_TRUNCATE
|
static int |
CACHEPATH_POLICY_ONE_DIRECTORY
|
| Constructor Summary | |
|---|---|
DiskCache2(java.lang.String root,
boolean reletiveToHome,
int persistMinutes,
int scourEveryMinutes)
Create a cache on disk. |
|
| Method Summary | |
|---|---|
void |
cleanCache(java.io.File dir,
java.lang.StringBuffer sbuff,
boolean isRoot)
Remove any files or directories whose last modified time greater than persistMinutes |
void |
exit()
Be sure to call this when your application exits, otherwise the scour thread may not die. |
java.io.File |
getCacheFile(java.lang.String fileLocation)
Get a File in the cache, corresponding to the fileLocation. |
java.lang.String |
getRootDirectory()
Get the cache root directory. |
static void |
main(java.lang.String[] args)
debug |
void |
setCachePathPolicy(int cachePathPolicy,
java.lang.String cachePathPolicyParam)
CACHEPATH_POLICY_ONE_DIRECTORY (default) : replace "/" with "-", so all files are in one directory. |
void |
setLogger(org.slf4j.Logger cacheLog)
Optionally set a logger. |
void |
setRootDirectory(java.lang.String cacheDir)
|
void |
showCache(java.io.PrintStream pw)
Show cache contents. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static int CACHEPATH_POLICY_ONE_DIRECTORY
public static int CACHEPATH_POLICY_NESTED_DIRECTORY
public static int CACHEPATH_POLICY_NESTED_TRUNCATE
| Constructor Detail |
|---|
public DiskCache2(java.lang.String root,
boolean reletiveToHome,
int persistMinutes,
int scourEveryMinutes)
root - the root directory of the cache. Must be writeable.reletiveToHome - if the root directory is reletive to the cache home directory.persistMinutes - how old a file should be before deleting.scourEveryMinutes - how often to run the scour process. If <= 0, dont scour.| Method Detail |
|---|
public void exit()
public void setLogger(org.slf4j.Logger cacheLog)
public void setRootDirectory(java.lang.String cacheDir)
public java.lang.String getRootDirectory()
public java.io.File getCacheFile(java.lang.String fileLocation)
fileLocation - logical file location
public void setCachePathPolicy(int cachePathPolicy,
java.lang.String cachePathPolicyParam)
public void showCache(java.io.PrintStream pw)
pw - write to this PrintStream.
public void cleanCache(java.io.File dir,
java.lang.StringBuffer sbuff,
boolean isRoot)
public static void main(java.lang.String[] args)
throws java.io.IOException
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||