net.i2p.data
public class SDSCache<V extends SimpleDataStructure> extends Object
private static final SDSCache_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); }
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 V get(byte[] data)
data
- non-null, the byte array for the SimpleDataStructureIllegalArgumentException
- if data is not the correct number of bytesNPE
public V get(byte[] b, int off)
public V get(InputStream in) throws IOException
IOException