OffHeapByteBuffer implements OffHeapStore { public byte[] remove(Pointer pointer) { readWriteLock.writeLock(pointer.getPosition()); try { final byte[] payload = retrieve(pointer); dirtyMemory.addAndGet(payload.length + POINTER_SIZE); markAsDirty(pointer.getPosition()); return payload; } finally { readWriteLock.writeUnlock(pointer.getPosition()); } } OffHeapByteBuffer(int index, int capacity);  OffHeapByteBuffer(int index, int capacity, int concurrencyLevel); byte[] retrieve(final Pointer pointer); byte[] remove(Pointer pointer); Pointer store(final byte[] payload, final long expiry); Pointer store(final Allocation allocation, byte[] payload, final long expiry); Pointer update(final Pointer pointer, final byte[] payload, final long expiry); void free(); long dirtyMemory(); long usedMemory(); long freeMemory(); int getIndex(); final static int DEFAULT_CONCURRENCY_LEVEL; }
@Test public void remove() { int size = 100; final long expiry = System.currentTimeMillis(); byte[] expectedBytes = new byte[size]; random.nextBytes(expectedBytes); Pointer pointer = buffer.store(expectedBytes, expiry); byte[] actualBytes = buffer.remove(pointer); assertArrayEquals(expectedBytes, actualBytes); }