public class CacheManager
extends java.lang.Object
Constructor and Description |
---|
CacheManager()
Default constructor; does nothing.
|
Modifier and Type | Method and Description |
---|---|
static void |
addCacheListener(java.awt.event.ActionListener a)
Add a listener that gets called when we clear the full cache
|
static void |
clearCache()
Clear the cache.
|
static java.util.Hashtable |
findOrCreate(java.lang.Object owner)
Find the cache associated with
owner and if not there,
create a new cache |
static java.lang.Object |
get(java.lang.Object owner,
java.lang.Object key)
Get the cached object.
|
static java.lang.Object |
get(java.lang.Object owner,
java.lang.Object key,
boolean force)
Get the cached object.
|
static byte[] |
getCachedFile(java.lang.String group,
java.lang.String id)
Get the cached file under the group id if it exists
|
static java.io.File |
getCachedFilePath(java.lang.String group,
java.lang.String id)
Get the cached file under the group id if it exists
|
static java.io.File |
getCacheGroupDir(java.lang.String group)
What dir is the cache group in
|
static boolean |
getDoCache()
Get whether we are caching or not
|
static java.io.File |
getTmpDir()
get tmp dir
|
static java.io.File |
getTmpFile(java.lang.String prefix)
get a tmp file
|
static void |
printStats()
Print the statistics for this cache.
|
static void |
put(java.lang.Object owner,
java.lang.Object key,
java.lang.Object value)
Put an object in the cache
|
static void |
put(java.lang.Object owner,
java.lang.Object key,
java.lang.Object value,
boolean force)
Put an object in the cache
|
static void |
putCachedFile(java.lang.String group,
java.lang.String id,
byte[] bytes)
Write the cached file
|
static void |
remove(java.lang.Object owner)
Remove the cache associated with the
owner . |
static void |
remove(java.lang.Object owner,
java.lang.Object key)
Remove a particular item from the owner's cache.
|
static void |
setCacheDir(java.io.File dir)
set the cache dir
|
static void |
setDoCache(boolean cache)
Set whether we do caching.
|
static void |
setMaxFileCacheSize(long maxSize)
Set the max limit on the file cache size
|
static void |
setTmpDir(java.io.File dir)
Set the tmp dir
|
public static void setDoCache(boolean cache)
cache
- Do we do cachingpublic static boolean getDoCache()
public static void setCacheDir(java.io.File dir)
dir
- cache dirpublic static void setTmpDir(java.io.File dir)
dir
- tmp dirpublic static java.io.File getTmpDir()
public static java.io.File getTmpFile(java.lang.String prefix)
prefix
- file prefixpublic static java.io.File getCacheGroupDir(java.lang.String group)
group
- cache grouppublic static java.io.File getCachedFilePath(java.lang.String group, java.lang.String id)
group
- groupid
- idpublic static byte[] getCachedFile(java.lang.String group, java.lang.String id)
group
- groupid
- idpublic static void setMaxFileCacheSize(long maxSize)
maxSize
- Max cache sizepublic static void putCachedFile(java.lang.String group, java.lang.String id, byte[] bytes)
group
- groupid
- idbytes
- bytespublic static void put(java.lang.Object owner, java.lang.Object key, java.lang.Object value)
owner
- owner of the objectkey
- key for the cached objectvalue
- value for keypublic static void put(java.lang.Object owner, java.lang.Object key, java.lang.Object value, boolean force)
owner
- owner of the objectkey
- key for the cached objectvalue
- value for keyforce
- true to cache even if doCache is falsepublic static void clearCache()
public static void addCacheListener(java.awt.event.ActionListener a)
a
- cache listenerpublic static java.util.Hashtable findOrCreate(java.lang.Object owner)
owner
and if not there,
create a new cacheowner
- owner to search forpublic static java.lang.Object get(java.lang.Object owner, java.lang.Object key)
owner
- cache ownerkey
- key within the cachepublic static java.lang.Object get(java.lang.Object owner, java.lang.Object key, boolean force)
owner
- cache ownerkey
- key within the cacheforce
- true to force a lookuppublic static void remove(java.lang.Object owner)
owner
.owner
- owner of the cachepublic static void remove(java.lang.Object owner, java.lang.Object key)
owner
- owner of the cachekey
- key for object to removepublic static void printStats()