Skip to content

Lightweight, fully-featured, idiomatic cross-platform Zig bindings to Lightning Memory-Mapped Database (LMDB).

License

Notifications You must be signed in to change notification settings

lithdew/lmdb-zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lmdb-zig

Lightweight, fully-featured, idiomatic cross-platform Zig bindings to Lightning Memory-Mapped Database (LMDB).

LMDB is a tiny, extraordinarily fast Btree-based embedded KV database with some excellent properties:

  • Zero-copy lookup and iteration: the entire database is memory-mapped.
  • Transactions may create, drop, and interact with multiple named databases at once.
  • Multiple readers, single writer. Writers don't block readers, readers don't block writers.
  • Keys are lexicographically sorted by default. A custom key ordering may be defined per named database.
  • Zero maintenance: does not require any compaction, external processes, or background threads running.
  • Entire database is exposed as a single file accompanied by a lockfile. A single database file may comprise of multiple named databases.
  • Fully exploits the operating system's buffer cache given its memory mapping and compact size being a mere 32KB worth of object code.

Refer to the 12 extensive unit tests provided here for usage instructions and guidelines.

Built and tested against Zig's master branch over all possible optimization modes.

Motivation

These bindings were built in mind for utilizing LMDB as the underlying backend of a database project.

As a result, extensive effort was put into exposing and testing as many different aspects of LMDB's functionality as possible with an emphasis on minimal overhead, such as fixed memory map addressing, in-place cursor updates, duplicate keys, on-the-fly backups, crash recovery, etc.

Setup

These bindings were built with first-class support for the zigmod package manager.

To incorporate these bindings into your project, include the following into your project's zig.mod:

- type: git
  path: https://github.com/lithdew/lmdb-zig

Afterwards, run:

zigmod fetch

Status

Presently, these bindings completely cover the entire API surface for LMDB except for the list of methods provided below that were deemed unnecessary. In the case you require any of these methods exported, please file an issue describing your use case.

About

Lightweight, fully-featured, idiomatic cross-platform Zig bindings to Lightning Memory-Mapped Database (LMDB).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published