Search code examples
openldaplmdbnosql

Values that can be stored in LMDB


LMDB is a key-value store. What types of keys and values can be stored here? Examples shows either int or char arrays.. Also I would like to know if it is possible to store related data in lmdb like we store all data related to a student in a table in RDBMS


Solution

  • It sounds like you're not a C programmer, but in the context of the C language, the data for keys and values in LMDB are both (void *) - that is, generic pointers to anything. That means any data type that can be expressed in the programming language can be used. In other languages, through whatever bindings are provided, your options may be more limited.

    LMDB doesn't care what you store, all it sees are blobs. Obviously it is not an RDBMS. If you want to store structured data, you need to manage that structure yourself. You could take a complex data structure and serialize it into a blob, and store it under a single key. This is the approach used in OpenLDAP's slapd. Or, you could setup individual columns of your data as separate named DBs in LMDB and store individual values in their respective DBs. (For example, indices in OpenLDAP and SQLite/SQLightning are handled this way.) So yes, while LMDB does not provide any functions for managing relations itself, you can certainly use it as the backing store of an RDBMS if you want to. (Again, see SQLightning for example. Backends for MySQL/MariaDB or Postgres are doable as well, but involve a lot more glue code between their frontends and the LMDB API.)