可以存储在LMDB中的值 [英] Values that can be stored in LMDB

查看:120
本文介绍了可以存储在LMDB中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

LMDB是键值存储.可以在此处存储哪些类型的键和值?示例显示intchar arrays.此外,我想知道是否可以将相关数据存储在lmdb中,就像我们将与学生有关的所有数据存储在RDBMS中的table

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

推荐答案

听起来您不是C程序员,但是在C语言的上下文中,LMDB中键和值的数据都是(void * )-也就是说,指向任何内容的通用指针.这意味着可以使用可以用编程语言表达的任何数据类型.在其他语言中,通过提供的任何绑定,您的选择可能会受到更多限制.

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不在乎您存储什么,它看到的只是斑点.显然,它不是RDBMS.如果要存储结构化数据,则需要自己管理该结构.您可以采用复杂的数据结构并将其序列化为Blob,并将其存储在单个键下.这是OpenLDAP的slapd中使用的方法.或者,您可以将数据的各个列设置为LMDB中的独立命名数据库,并将各个值存储在它们各自的DB中. (例如,以这种方式处理OpenLDAP和SQLite/SQLightning中的索引.)是的,虽然LMDB本身不提供任何管理关系的功能,但是如果需要,您当然可以将其用作RDBMS的后备存储. (再次,例如,参见SQLightning.MySQL/MariaDB或Postgres的后端也是可行的,但是在它们的前端和LMDB API之间涉及很多粘合代码.)

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.)

这篇关于可以存储在LMDB中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆