public class DataCacheManager extends Object implements Runnable
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.
Modifier and Type | Method and Description |
---|---|
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
|
public static DataCacheManager getCacheManager()
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 idpublic Object addToCache(double[] values)
values
- the values to addpublic Object addToCache(String what, double[] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addpublic 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 limitspublic float[] getFloatArray1D(Object cacheId)
cacheId
- the cache idpublic Object addToCache(float[] values)
values
- the values to addpublic Object addToCache(String what, float[] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addpublic 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 limitspublic int[] getIntArray1D(Object cacheId)
cacheId
- the cache idpublic Object addToCache(int[] values)
values
- the values to addpublic Object addToCache(String what, int[] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addpublic 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 limitspublic short[] getShortArray1D(Object cacheId)
cacheId
- the cache idpublic Object addToCache(short[] values)
values
- the values to addpublic Object addToCache(String what, short[] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addpublic 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 limitspublic byte[] getByteArray1D(Object cacheId)
cacheId
- the cache idpublic Object addToCache(byte[] values)
values
- the values to addpublic Object addToCache(String what, byte[] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addpublic 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 limitspublic double[][] getDoubleArray2D(Object cacheId)
cacheId
- the cache idpublic Object addToCache(double[][] values)
values
- the values to addpublic Object addToCache(String what, double[][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addpublic 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 limitspublic float[][] getFloatArray2D(Object cacheId)
cacheId
- the cache idpublic Object addToCache(float[][] values)
values
- the values to addpublic Object addToCache(String what, float[][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addpublic 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 limitspublic int[][] getIntArray2D(Object cacheId)
cacheId
- the cache idpublic Object addToCache(int[][] values)
values
- the values to addpublic Object addToCache(String what, int[][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addpublic 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 limitspublic short[][] getShortArray2D(Object cacheId)
cacheId
- the cache idpublic Object addToCache(short[][] values)
values
- the values to addpublic Object addToCache(String what, short[][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addpublic 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 limitspublic byte[][] getByteArray2D(Object cacheId)
cacheId
- the cache idpublic Object addToCache(byte[][] values)
values
- the values to addpublic Object addToCache(String what, byte[][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addpublic 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 limitspublic double[][][] getDoubleArray3D(Object cacheId)
cacheId
- the cache idpublic Object addToCache(double[][][] values)
values
- the values to addpublic Object addToCache(String what, double[][][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addpublic 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 limitspublic float[][][] getFloatArray3D(Object cacheId)
cacheId
- the cache idpublic Object addToCache(float[][][] values)
values
- the values to addpublic Object addToCache(String what, float[][][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addpublic 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 limitspublic int[][][] getIntArray3D(Object cacheId)
cacheId
- the cache idpublic Object addToCache(int[][][] values)
values
- the values to addpublic Object addToCache(String what, int[][][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addpublic 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 limitspublic short[][][] getShortArray3D(Object cacheId)
cacheId
- the cache idpublic Object addToCache(short[][][] values)
values
- the values to addpublic Object addToCache(String what, short[][][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addpublic 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 limitspublic byte[][][] getByteArray3D(Object cacheId)
cacheId
- the cache idpublic Object addToCache(byte[][][] values)
values
- the values to addpublic Object addToCache(String what, byte[][][] values)
what
- the name of the item. used for tracking cache behaviorvalues
- the values to addpublic 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 limitsCopyright © 1996–2023 The SSEC Visualization Project. All rights reserved.