class OffHeapByteBuffer implements OffHeapStore {

  public Pointer update(final Pointer pointer, final byte[] payload, final long expiry) {
    readWriteLock.writeLock(pointer.getPosition());
    try {
      final byte[] exPayload = retrieve(pointer);
      if (exPayload.length >= payload.length) {
        // Note that updated payload should be always less than
        // exPayload,
        // otherwise new location is allocated.
        dirtyMemory.addAndGet(exPayload.length - payload.length);
        final Allocation allocation = new Allocation(pointer.getPosition(),
            payload.length + POINTER_SIZE);
        return store(allocation, payload, expiry);
      } else {
        dirtyMemory.addAndGet(exPayload.length + POINTER_SIZE);
        markAsDirty(pointer.getPosition());
        return store(payload, expiry);
      }
    } finally {
      readWriteLock.writeUnlock(pointer.getPosition());
    }
  }

  public  OffHeapByteBuffer(int index, int capacity);
  public  OffHeapByteBuffer(int index, int capacity, int concurrencyLevel);

}