Collections & Testing

Collections

A Collection is a named, separate MMKV file — reach for one when a set of documents needs its own lifecycle or access boundary: a wipe-on-logout cache, per-user scoping, or an encryption boundary. See Opening Documents for how to open one.

Testing with an in-memory backend

Documents.inMemory() returns a Collection with identical semantics, backed by an in-memory map instead of a real MMKV file — no device, no simulator, no disk state to clean up between tests:

val store = Documents.inMemory()
val note = store.document<Note>("note-1")

note.set(Note(title = "Test note"))
assertEquals("Test note", note.get()?.title)

Every store here — the default store, every named collection, and the in-memory backend alike — is single-process only; see Overview for the constraint that applies across all of them.