Embedded, ACID, key-value database for ZIO — zero infrastructure, zero ops, just a file.
Built on lmdb-java with a type-safe, ZIO-native API:
- Three collection kinds —
LMDBCollection(1 key → 1 value),LMDBMulti(1 key → N values),LMDBIndex(1 key → N keys) - JSON by default —
derives LMDBCodecJsonis all it takes; custom codecs are supported - Honest types — every function signature tells you exactly what can fail
- Atomic transactions — single-collection or cross-collection, always consistent
- Lexicographic ordering — keys are sorted; range scans and pagination come for free
- Scala-CLI friendly — add one dependency line and run
// sbt
libraryDependencies += "fr.janalyse" %% "zio-lmdb" % "2.8.1"
// scala-cli
//> using dep fr.janalyse::zio-lmdb:2.8.1
//> using javaOpt --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMEDimport zio.*, zio.lmdb.*, zio.lmdb.json.*
import java.util.UUID
case class Person(name: String, age: Int) derives LMDBCodecJson
object Example extends ZIOAppDefault:
def run = (for {
people <- LMDB.collectionCreate[UUID, Person]("people", failIfExists = false)
id <- Random.nextUUID
_ <- people.upsertOverwrite(id, Person("Alice", 30))
_ <- people.upsert(id, _.map(p => p.copy(age = p.age + 1)).getOrElse(Person("Alice", 30)))
result <- people.fetch(id)
_ <- Console.printLine(result)
} yield ()).provide(LMDB.liveWithDatabaseName("my-app"), Scope.default)Full API reference, transactions, codecs, indexes, query DSL and configuration:
dacr.github.io/zio-lmdb
- sotohp — photo management, uses zio-lmdb intensively
- code-examples-manager — snippets and gist management
- zwords — a Wordle-like game (play it)