user7256215
user7256215

Reputation:

LMDB modus operandi

I just started to replace some SQL tables with LMDB, which is a basic key-value store implemented in C (lmdb link).

During the porting, I faced some theoretical questions:

  1. The DB uses a cursor instead of a typed key, I assumed it's since the key can be varied according to the requirement (blob), is it so?

  2. LMDB maps the databases into memory and it is synced to file only upon transaction commit. How do I maintain integrity in a multi-process environment? Is the memory shared amongst all users?

  3. Also, when I tried to remove an item from the DB (using mdb_del), it didn't remove it, but just marked it as removed. So it looks like the DB file doesn't ever get smaller, since there's no memory reuse. What's the benefit of this approach?

    Perhaps there's a source that explain in details how it works?

Upvotes: 0

Views: 401

Answers (1)

Yigal Eilam
Yigal Eilam

Reputation: 77

  1. You can search by a key "where Key=k". Cursor lets you find the first, last, next or previous key. Cursor also lets you search "where Key>=k". (I found it useful)

  2. LMDB supports one writer and many readers. It works for me (Visual Studio using lmdb.v140). The only serverless database I found to be able do that.

  3. N/C

Upvotes: 2

Related Questions