public class SDSCache<V extends SimpleDataStructure> extends Object
private static final SDSCache<Foo> _cache = new SDSCache(Foo.class, LENGTH, 1024); public static Foo create(byte[] data) { return _cache.get(data); } public static Foo create(byte[] data, int off) { return _cache.get(data, off); } public static Foo create(InputStream in) throws IOException { return _cache.get(in); }
Constructor and Description |
---|
SDSCache(Class<V> rvClass,
int len,
int max) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
V |
get(byte[] data)
WARNING - If the SDS is found in the cache, the passed-in
byte array will be returned to the SimpleByteCache for reuse.
|
V |
get(byte[] b,
int off) |
V |
get(InputStream in) |
public SDSCache(Class<V> rvClass, int len, int max)
rvClass
- the class that we are storing, i.e. an extension of SimpleDataStructurelen
- the length of the byte array in the SimpleDataStructuremax
- maximum size of the cache assuming 128MB of mem.
The actual max size will be scaled based on available memory.public void clear()
public V get(byte[] data)
data
- non-null, the byte array for the SimpleDataStructureIllegalArgumentException
- if data is not the correct number of bytesNullPointerException
public V get(byte[] b, int off)
public V get(InputStream in) throws IOException
IOException