|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object visad.data.DataCacheManager
public class DataCacheManager
This provides a global cache for primitive array data You access it via the singelton:
DataCacheManager.getCacheManager()Client objects can store their data with:
Object cacheId = DataCacheManager.getCacheManager().addToCache(theData);Where data can be 1D or 2D byte/float/int/double arrays If the data changes then update the cache with:
DataCacheManager.getCacheManager().updateData(cacheId, newData);When the client object is finalized or is finished with the data call:
DataCacheManager.getCacheManager().removeFromCache(cacheId);When you want to access the data use one of:
DataCacheManager.getCacheManager().getByteArray1D(cacheId); DataCacheManager.getCacheManager().getByteArray2D(cacheId); DataCacheManager.getCacheManager().getFloatArray1D(cacheId); DataCacheManager.getCacheManager().getFloatArray2D(cacheId); DataCacheManager.getCacheManager().getShortArray1D(cacheId); DataCacheManager.getCacheManager().getShortArray2D(cacheId); DataCacheManager.getCacheManager().getIntArray1D(cacheId); DataCacheManager.getCacheManager().getIntArray2D(cacheId); DataCacheManager.getCacheManager().getDoubleArray1D(cacheId); DataCacheManager.getCacheManager().getDoubleArray2D(cacheId);The cachemanager will keep the data arrays in memory until the total size is greater than getMaxSize(). Then it will serialize the data arrays in a least recently used manner until the totalSize less than the max size.
Method Summary | |
---|---|
Object |
addToCache(byte[] values)
add the data to the cache |
Object |
addToCache(byte[][] values)
add the data to the cache |
Object |
addToCache(byte[][][] values)
add the data to the cache |
Object |
addToCache(double[] values)
add the data to the cache |
Object |
addToCache(double[][] values)
add the data to the cache |
Object |
addToCache(double[][][] values)
add the data to the cache |
Object |
addToCache(float[] values)
add the data to the cache |
Object |
addToCache(float[][] values)
add the data to the cache |
Object |
addToCache(float[][][] values)
add the data to the cache |
Object |
addToCache(int[] values)
add the data to the cache |
Object |
addToCache(int[][] values)
add the data to the cache |
Object |
addToCache(int[][][] values)
add the data to the cache |
Object |
addToCache(short[] values)
add the data to the cache |
Object |
addToCache(short[][] values)
add the data to the cache |
Object |
addToCache(short[][][] values)
add the data to the cache |
Object |
addToCache(String what,
byte[] values)
add the data to the cache |
Object |
addToCache(String what,
byte[][] values)
add the data to the cache |
Object |
addToCache(String what,
byte[][][] values)
add the data to the cache |
Object |
addToCache(String what,
byte[][][] values,
boolean removeIfNeeded)
add the data to the cache |
Object |
addToCache(String what,
byte[][] values,
boolean removeIfNeeded)
add the data to the cache |
Object |
addToCache(String what,
byte[] values,
boolean removeIfNeeded)
add the data to the cache |
Object |
addToCache(String what,
double[] values)
add the data to the cache |
Object |
addToCache(String what,
double[][] values)
add the data to the cache |
Object |
addToCache(String what,
double[][][] values)
add the data to the cache |
Object |
addToCache(String what,
double[][][] values,
boolean removeIfNeeded)
add the data to the cache |
Object |
addToCache(String what,
double[][] values,
boolean removeIfNeeded)
add the data to the cache |
Object |
addToCache(String what,
double[] values,
boolean removeIfNeeded)
add the data to the cache |
Object |
addToCache(String what,
float[] values)
add the data to the cache |
Object |
addToCache(String what,
float[][] values)
add the data to the cache |
Object |
addToCache(String what,
float[][][] values)
add the data to the cache |
Object |
addToCache(String what,
float[][][] values,
boolean removeIfNeeded)
add the data to the cache |
Object |
addToCache(String what,
float[][] values,
boolean removeIfNeeded)
add the data to the cache |
Object |
addToCache(String what,
float[] values,
boolean removeIfNeeded)
add the data to the cache |
Object |
addToCache(String what,
int[] values)
add the data to the cache |
Object |
addToCache(String what,
int[][] values)
add the data to the cache |
Object |
addToCache(String what,
int[][][] values)
add the data to the cache |
Object |
addToCache(String what,
int[][][] values,
boolean removeIfNeeded)
add the data to the cache |
Object |
addToCache(String what,
int[][] values,
boolean removeIfNeeded)
add the data to the cache |
Object |
addToCache(String what,
int[] values,
boolean removeIfNeeded)
add the data to the cache |
Object |
addToCache(String what,
short[] values)
add the data to the cache |
Object |
addToCache(String what,
short[][] values)
add the data to the cache |
Object |
addToCache(String what,
short[][][] values)
add the data to the cache |
Object |
addToCache(String what,
short[][][] values,
boolean removeIfNeeded)
add the data to the cache |
Object |
addToCache(String what,
short[][] values,
boolean removeIfNeeded)
add the data to the cache |
Object |
addToCache(String what,
short[] values,
boolean removeIfNeeded)
add the data to the cache |
void |
checkCache()
Check if we are above the max size. |
void |
flushAllCachedData()
|
byte[] |
getByteArray1D(Object cacheId)
get the value from the cache |
byte[][] |
getByteArray2D(Object cacheId)
get the value from the cache |
byte[][][] |
getByteArray3D(Object cacheId)
get the value from the cache |
File |
getCacheDir()
get the cache dir. |
File |
getCacheFile()
|
static DataCacheManager |
getCacheManager()
The singleton access |
double[] |
getDoubleArray1D(Object cacheId)
get the value from the cache |
double[][] |
getDoubleArray2D(Object cacheId)
get the value from the cache |
double[][][] |
getDoubleArray3D(Object cacheId)
get the value from the cache |
float[] |
getFloatArray1D(Object cacheId)
get the value from the cache |
float[][] |
getFloatArray2D(Object cacheId)
get the value from the cache |
float[][][] |
getFloatArray3D(Object cacheId)
get the value from the cache |
Object |
getId()
Get a unique id |
int[] |
getIntArray1D(Object cacheId)
get the value from the cache |
int[][] |
getIntArray2D(Object cacheId)
get the value from the cache |
int[][][] |
getIntArray3D(Object cacheId)
get the value from the cache |
int |
getMaxSize()
|
short[] |
getShortArray1D(Object cacheId)
get the value from the cache |
short[][] |
getShortArray2D(Object cacheId)
get the value from the cache |
short[][][] |
getShortArray3D(Object cacheId)
get the value from the cache |
String |
getStats()
|
boolean |
inMemory(Object cacheId)
|
void |
printStats()
Print out the cache statistics |
void |
removeFromCache(Object cacheId)
Remove the item from the cache |
void |
run()
|
void |
setCacheDir(File f)
set the directory to write files to |
void |
setMemoryPercent(double percentage)
|
void |
updateData(Object cacheId,
Object data)
the data has changed for the given cache id |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static DataCacheManager getCacheManager()
public void run()
run
in interface Runnable
public void setCacheDir(File f)
f
- dirpublic File getCacheDir()
public Object getId()
public void updateData(Object cacheId, Object data)
cacheId
- cache iddata
- the new datapublic boolean inMemory(Object cacheId)
public File getCacheFile()
public void removeFromCache(Object cacheId)
cacheId
- the cache idpublic void flushAllCachedData()
public void setMemoryPercent(double percentage)
public int getMaxSize()
public void checkCache()
public void printStats()
public String getStats()
public double[] getDoubleArray1D(Object cacheId)
cacheId
- the cache id
public Object addToCache(double[] values)
values
- the values to add
public Object addToCache(String what, double[] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to add
public Object addToCache(String what, double[] values, boolean removeIfNeeded)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addremoveIfNeeded
- If true then this data will not be written to disk and will be removed from the cache
when the cache is exceeding memory limits
public float[] getFloatArray1D(Object cacheId)
cacheId
- the cache id
public Object addToCache(float[] values)
values
- the values to add
public Object addToCache(String what, float[] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to add
public Object addToCache(String what, float[] values, boolean removeIfNeeded)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addremoveIfNeeded
- If true then this data will not be written to disk and will be removed from the cache
when the cache is exceeding memory limits
public int[] getIntArray1D(Object cacheId)
cacheId
- the cache id
public Object addToCache(int[] values)
values
- the values to add
public Object addToCache(String what, int[] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to add
public Object addToCache(String what, int[] values, boolean removeIfNeeded)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addremoveIfNeeded
- If true then this data will not be written to disk and will be removed from the cache
when the cache is exceeding memory limits
public short[] getShortArray1D(Object cacheId)
cacheId
- the cache id
public Object addToCache(short[] values)
values
- the values to add
public Object addToCache(String what, short[] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to add
public Object addToCache(String what, short[] values, boolean removeIfNeeded)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addremoveIfNeeded
- If true then this data will not be written to disk and will be removed from the cache
when the cache is exceeding memory limits
public byte[] getByteArray1D(Object cacheId)
cacheId
- the cache id
public Object addToCache(byte[] values)
values
- the values to add
public Object addToCache(String what, byte[] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to add
public Object addToCache(String what, byte[] values, boolean removeIfNeeded)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addremoveIfNeeded
- If true then this data will not be written to disk and will be removed from the cache
when the cache is exceeding memory limits
public double[][] getDoubleArray2D(Object cacheId)
cacheId
- the cache id
public Object addToCache(double[][] values)
values
- the values to add
public Object addToCache(String what, double[][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to add
public Object addToCache(String what, double[][] values, boolean removeIfNeeded)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addremoveIfNeeded
- If true then this data will not be written to disk and will be removed from the cache
when the cache is exceeding memory limits
public float[][] getFloatArray2D(Object cacheId)
cacheId
- the cache id
public Object addToCache(float[][] values)
values
- the values to add
public Object addToCache(String what, float[][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to add
public Object addToCache(String what, float[][] values, boolean removeIfNeeded)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addremoveIfNeeded
- If true then this data will not be written to disk and will be removed from the cache
when the cache is exceeding memory limits
public int[][] getIntArray2D(Object cacheId)
cacheId
- the cache id
public Object addToCache(int[][] values)
values
- the values to add
public Object addToCache(String what, int[][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to add
public Object addToCache(String what, int[][] values, boolean removeIfNeeded)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addremoveIfNeeded
- If true then this data will not be written to disk and will be removed from the cache
when the cache is exceeding memory limits
public short[][] getShortArray2D(Object cacheId)
cacheId
- the cache id
public Object addToCache(short[][] values)
values
- the values to add
public Object addToCache(String what, short[][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to add
public Object addToCache(String what, short[][] values, boolean removeIfNeeded)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addremoveIfNeeded
- If true then this data will not be written to disk and will be removed from the cache
when the cache is exceeding memory limits
public byte[][] getByteArray2D(Object cacheId)
cacheId
- the cache id
public Object addToCache(byte[][] values)
values
- the values to add
public Object addToCache(String what, byte[][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to add
public Object addToCache(String what, byte[][] values, boolean removeIfNeeded)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addremoveIfNeeded
- If true then this data will not be written to disk and will be removed from the cache
when the cache is exceeding memory limits
public double[][][] getDoubleArray3D(Object cacheId)
cacheId
- the cache id
public Object addToCache(double[][][] values)
values
- the values to add
public Object addToCache(String what, double[][][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to add
public Object addToCache(String what, double[][][] values, boolean removeIfNeeded)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addremoveIfNeeded
- If true then this data will not be written to disk and will be removed from the cache
when the cache is exceeding memory limits
public float[][][] getFloatArray3D(Object cacheId)
cacheId
- the cache id
public Object addToCache(float[][][] values)
values
- the values to add
public Object addToCache(String what, float[][][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to add
public Object addToCache(String what, float[][][] values, boolean removeIfNeeded)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addremoveIfNeeded
- If true then this data will not be written to disk and will be removed from the cache
when the cache is exceeding memory limits
public int[][][] getIntArray3D(Object cacheId)
cacheId
- the cache id
public Object addToCache(int[][][] values)
values
- the values to add
public Object addToCache(String what, int[][][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to add
public Object addToCache(String what, int[][][] values, boolean removeIfNeeded)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addremoveIfNeeded
- If true then this data will not be written to disk and will be removed from the cache
when the cache is exceeding memory limits
public short[][][] getShortArray3D(Object cacheId)
cacheId
- the cache id
public Object addToCache(short[][][] values)
values
- the values to add
public Object addToCache(String what, short[][][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to add
public Object addToCache(String what, short[][][] values, boolean removeIfNeeded)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addremoveIfNeeded
- If true then this data will not be written to disk and will be removed from the cache
when the cache is exceeding memory limits
public byte[][][] getByteArray3D(Object cacheId)
cacheId
- the cache id
public Object addToCache(byte[][][] values)
values
- the values to add
public Object addToCache(String what, byte[][][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to add
public Object addToCache(String what, byte[][][] values, boolean removeIfNeeded)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addremoveIfNeeded
- If true then this data will not be written to disk and will be removed from the cache
when the cache is exceeding memory limits
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |