这是用户在 2024-5-7 15:52 为 http://www.lmdb.tech/doc/ 保存的双语快照页面,由 沉浸式翻译 提供双语支持。了解如何保存?
LMDB
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Lightning Memory-Mapped Database Manager (LMDB)

Introduction 引言

LMDB is a Btree-based database management library modeled loosely on the BerkeleyDB API, but much simplified. The entire database is exposed in a memory map, and all data fetches return data directly from the mapped memory, so no malloc's or memcpy's occur during data fetches. As such, the library is extremely simple because it requires no page caching layer of its own, and it is extremely high performance and memory-efficient. It is also fully transactional with full ACID semantics, and when the memory map is read-only, the database integrity cannot be corrupted by stray pointer writes from application code.
LMDB 是一个基于 B 树的数据库管理库,其模型大致基于 BerkeleyDB API,但进行了大幅简化。整个数据库以内存映射的形式暴露出来,所有数据获取都是直接从映射内存中返回数据,因此在数据获取过程中不会发生 malloc 或 memcpy 操作。因此,该库非常简单,因为它不需要自己的页面缓存层,同时具有极高的性能和内存效率。它还具有完全的事务性,具备完整的 ACID 语义,并且当内存映射为只读时,数据库完整性不会被应用程序代码中的随机指针写入所破坏。

The library is fully thread-aware and supports concurrent read/write access from multiple processes and threads. Data pages use a copy-on- write strategy so no active data pages are ever overwritten, which also provides resistance to corruption and eliminates the need of any special recovery procedures after a system crash. Writes are fully serialized; only one write transaction may be active at a time, which guarantees that writers can never deadlock. The database structure is multi-versioned so readers run with no locks; writers cannot block readers, and readers don't block writers.
该库是完全线程感知的,并支持从多个进程和线程进行并发读/写访问。数据页使用写时复制策略,因此不会覆盖任何活动数据页,这也提供了对损坏的抵抗力,并消除了系统崩溃后需要任何特殊恢复程序的需求。写入是完全序列化的;任何时候只能有一个写事务处于活动状态,这保证了写入者永远不会死锁。数据库结构是多版本的,因此读取器在不加锁的情况下运行;写入者不会阻塞读取者,读取者也不会阻塞写入者。

Unlike other well-known database mechanisms which use either write-ahead transaction logs or append-only data writes, LMDB requires no maintenance during operation. Both write-ahead loggers and append-only databases require periodic checkpointing and/or compaction of their log or database files otherwise they grow without bound. LMDB tracks free pages within the database and re-uses them for new write operations, so the database size does not grow without bound in normal use.
与使用预写事务日志或仅追加数据写入的其他知名数据库机制不同,LMDB 在操作期间不需要维护。预写日志器和仅追加数据库都需要定期检查点和/或压缩其日志或数据库文件,否则它们会无限增长,而 LMDB 跟踪数据库内的空闲页并将其重新用于新的写操作,因此数据库大小在正常使用中不会无限增长。

The memory map can be used as a read-only or read-write map. It is read-only by default as this provides total immunity to corruption. Using read-write mode offers much higher write performance, but adds the possibility for stray application writes thru pointers to silently corrupt the database. Of course if your application code is known to be bug-free (...) then this is not an issue.
翻译文本 开始:

If this is your first time using a transactional embedded key/value store, you may find the Getting Started page to be helpful.
内存映射可以用作只读或读写映射。它默认是只读的,这样可以完全免疫于损坏。使用读写模式提供了更高的写入性能,但增加了通过指针的意外应用程序写入可能会无声地破坏数据库的可能性。当然,如果你的应用程序代码已知是无错误的(...),那么这不是一个问题。

Caveats 如果你是第一次使用事务性嵌入式键值存储,你可能会发现“入门”页面很有帮助。

Troubleshooting the lock file, plus semaphores on BSD systems:
解决锁定文件问题,以及 BSD 系统上的信号量:

Restrictions/caveats (in addition to those listed for some functions):
修复方法:以拥有信号量的用户(可能是最后一个用户)或以 root 身份打开和关闭数据库,同时没有其他进程正在使用该数据库。

...when several processes can use a database concurrently:
避免在有活动交易的情况下挂起进程。这些交易随后会像上面所说的那样成为“长时间运行”的。此外,当写入者提交时挂起的读取交易有时可能会看到错误的数据。

Author
Howard Chu, Symas Corporation.
霍华德·楚,Symas 公司。

Redistribution and use in source and binary forms, with or without modification, are permitted only as authorized by the OpenLDAP Public License.
仅在获得 OpenLDAP 公共许可证授权的情况下,才允许以源代码和二进制形式重新分发和使用,无论是否经过修改。

A copy of this license is available in the file LICENSE in the top-level directory of the distribution or, alternatively, at http://www.OpenLDAP.org/license.html.
本许可证的副本可在分发顶层目录中的文件 LICENSE 中找到,或者,也可在 http://www.OpenLDAP.org/license.html 上查看。

Derived From: 源自于:
This code is derived from btree.c written by Martin Hedenfalk.
此代码源自 Martin Hedenfalk 编写的 btree.c。

Copyright (c) 2009, 2010 Martin Hedenfalk marti.nosp@m.n@bz.nosp@m.ero.s.nosp@m.e
版权所有(c)2009, 2010 Martin Hedenfalk martin@bzero.se

Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
本软件的使用、复制、修改和分发权,无论是否收费,均在此授予,但前提是必须保留上述版权声明和本许可声明,并将其包含在所有副本中。

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
本软件按“原样”提供,作者不提供任何形式的保证,包括所有隐含的适销性和适用性保证。在任何情况下,作者均不对任何特殊、直接、间接或后果性损害或任何因使用、数据或利润损失而导致的任何损害负责,无论是在合同行为、疏忽或其他侵权行为中,均由本软件的使用或性能引起。