deleteRange

fun deleteRange(from: Key? = null, to: Key? = null): Long

Deletes every key in [from, to], both bounds inclusive and both optional, and returns how many.

val retired = db.deleteRange(to = Key.of("event:2026-07-31"))
db.compact() // tombstones are reclaimed by compaction, not by this call

Retention by key range, for a store that keys by time — which is what a staging buffer and a payload archive both do, and the whole of their retention policy. It is the loop a caller would otherwise write, and writing it correctly means knowing four invariants of the layer below; see DocumentStore.deleteRange, which this delegates to unchanged.

Deliberately point deletes rather than a range tombstone, so it costs one tombstone per key and nothing at all in the format. Follow it with compact when the space matters: the tombstones are what make the keys disappear, and compaction is what makes the tombstones disappear.