public void updateValue(final Txn<ByteBuffer> writeTxn,
                            final ByteBuffer keyBuffer,
                            final Consumer<ByteBuffer> valueBufferConsumer) {
        Preconditions.checkArgument(!writeTxn.isReadOnly());

        try (Cursor<ByteBuffer> cursor = lmdbDbi.openCursor(writeTxn)) {

            boolean isFound = cursor.get(keyBuffer, GetOp.MDB_SET_KEY);
            if (!isFound) {
                throw new RuntimeException(LogUtil.message(
                        "Expecting to find entry for {}", ByteBufferUtils.byteBufferInfo(keyBuffer)));
            }
            final ByteBuffer valueBuf = cursor.val();

            // We run LMDB in its default mode of read only mmaps so we cannot mutate the key/value
            // bytebuffers.  Instead we must copy the content and put the replacement entry.
            // We could run LMDB in MDB_WRITEMAP mode which allows mutation of the buffers (and
            // thus avoids the buffer copy cost) but adds more risk of DB corruption. As we are not
            // doing a high volume of value mutations read-only mode is a safer bet.
            try (final PooledByteBuffer pooledValueBuffer = getPooledValueBuffer()) {
                final ByteBuffer newValueBuf = pooledValueBuffer.getByteBuffer();
                // First copy the current value as is
                ByteBufferUtils.copy(valueBuf, newValueBuf);

                // Now use the consumer to update the contents of the buffer
                valueBufferConsumer.accept(newValueBuf);

                // Only put if the buffer is different
                if (!valueBuf.equals(newValueBuf)) {
                    cursor.put(cursor.key(), newValueBuf, PutFlags.MDB_CURRENT);
                } else {
                    LOGGER.trace("put call skipped as buffers are the same");
                }
            }
        }
    }
Updates the value associated with the passed key using the valueBufferConsumer. A new {@link ByteBuffer}
will be populated from the current value and passed to valueBufferConsumer to mutate. This mutated buffer
should be left in a state ready to be read, i.e. flipped.
This method is intended for cases where you want to modify the value based on its current value, or
you only want to modify part of it without (de)serialising the whole.
stroom-lmdb/src/main/java/stroom/lmdb/AbstractLmdbDb.java