@Test
    void testKeyRange() {
        basicLmdbDb.put("key11", "value1", false);
        basicLmdbDb.put("key12", "value1", false);
        basicLmdbDb.put("key13", "value1", false);
        basicLmdbDb.put("key21", "value2", false);
        basicLmdbDb.put("key22", "value2", false);
        basicLmdbDb.put("key23", "value2", false);
        basicLmdbDb.put("key31", "value3", false);
        basicLmdbDb.put("key32", "value3", false);
        basicLmdbDb.put("key33", "value3", false);

        lmdbEnv.doWithReadTxn(txn -> {

            try (PooledByteBuffer pooledStartKeyBuffer = basicLmdbDb.getPooledKeyBuffer();
                    PooledByteBuffer pooledEndKeyBuffer = basicLmdbDb.getPooledKeyBuffer()) {

                ByteBuffer startKeyBuffer = pooledStartKeyBuffer.getByteBuffer();
                ByteBuffer endKeyBuffer = pooledEndKeyBuffer.getByteBuffer();

                final String startKey = "key2";
                final String endKey = "key3";
                basicLmdbDb.serializeKey(startKeyBuffer, startKey);
                basicLmdbDb.serializeKey(endKeyBuffer, endKey);
                LOGGER.info("{} => {}",
                        ByteBufferUtils.byteBufferInfo(startKeyBuffer),
                        ByteBufferUtils.byteBufferInfo(endKeyBuffer));

                final KeyRange<ByteBuffer> keyRange = KeyRange.closedOpen(startKeyBuffer, endKeyBuffer);

                basicLmdbDb.forEachEntryAsBytes(txn, keyRange, kvTuple -> {
                    LOGGER.info("{} - {}",
                            ByteBufferUtils.byteBufferInfo(kvTuple.key()),
                            ByteBufferUtils.byteBufferInfo(kvTuple.val()));
                });

                final List<String> keysFound = new ArrayList<>();

                basicLmdbDb.forEachEntry(txn, KeyRange.closedOpen(startKey, endKey), kvTuple -> {
                    keysFound.add(kvTuple.getKey());
                });

                assertThat(keysFound)
                        .containsExactly("key21", "key22", "key23");
            }
        });
    }
Comparing overwriting the same key N times vs putting N entries each with a different key
stroom-lmdb/src/test/java/stroom/lmdb/TestBasicLmdbDb.java