Package net.i2p.util
Class SimpleByteCache
java.lang.Object
net.i2p.util.SimpleByteCache
public final class SimpleByteCache extends Object
Like ByteCache but works directly with byte arrays, not ByteArrays.
These are designed to be small caches, so there's no cleaner task
like there is in ByteCache. And we don't zero out the arrays here.
Only the static methods are public here.
- Since:
- 0.8.3
-
Method Summary
Modifier and Type Method Description static byte[]
acquire(int size)
Get the next available array, either from the cache or a brand new onestatic void
clearAll()
Clear everything (memory pressure)static SimpleByteCache
getInstance(int size)
Get a cache responsible for arrays of the given sizestatic SimpleByteCache
getInstance(int cacheSize, int size)
Get a cache responsible for objects of the given sizestatic void
release(byte[] entry)
Put this array back onto the available cache for reuse
-
Method Details
-
getInstance
Get a cache responsible for arrays of the given size- Parameters:
size
- how large should the objects cached be?
-
getInstance
Get a cache responsible for objects of the given size- Parameters:
cacheSize
- how large we want the cache to grow (number of objects, NOT memory size) before discarding released objects.size
- how large should the objects cached be?
-
clearAll
public static void clearAll()Clear everything (memory pressure) -
acquire
public static byte[] acquire(int size)Get the next available array, either from the cache or a brand new one -
release
public static void release(byte[] entry)Put this array back onto the available cache for reuse
-