[![license](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE)
[![npm version](https://img.shields.io/npm/v/lmdb.svg?style=flat-square)](https://www.npmjs.org/package/lmdb)
[![npm downloads](https://img.shields.io/npm/dw/lmdb-store)](https://www.npmjs.org/package/lmdb)
[![get](https://img.shields.io/badge/get-8.5%20MOPS-yellow)](README.md)
[![put](https://img.shields.io/badge/put-1.7%20MOPS-yellow)](README.md)
This is an ultra-fast NodeJS and Deno interface to LMDB; probably the fastest and most efficient key-value/database interface that exists for storage and retrieval of structured JS data (objects, arrays, etc.) in a true persisted, scalable, [ACID compliant](https://en.wikipedia.org/wiki/ACID) database. It provides a simple interface for interacting with LMDB, as a key-value db, that makes it easy to fully leverage the power, crash-proof design, and efficiency of LMDB using intuitive JavaScript, and is designed to scale across multiple processes or threads. Several key features that make it idiomatic, highly performant, and easy to use LMDB efficiently:
* High-performance translation of JS values and data structures to/from binary key/value data
* Queueing asynchronous off-thread write operations with promise-based API
* Simple transaction management
* Iterable queries/cursors
* Record versioning and optimistic locking for scalability/concurrency
* Optional native off-main-thread compression with high-performance LZ4 compression <a href="https://github.com/kriszyp/db-benchmark"><img align="right" src="./assets/performance.png" width="380"/></a>
* And ridiculously fast and efficient, with integrated (de)serialization, data retrieval can be several times faster than `JSON` alone
`lmdb-js` is used in many heavy-use production applications, including as a high-performance cache for builds in [Parcel](https://parceljs.org/) and [Elasticsearch's Kibana](https://www.elastic.co/kibana/), as the storage layer for [HarperDB](https://harperdb.io/) and [Gatsby](https://www.gatsbyjs.com/)'s database, and for search and analytical engine for our [clinical medical research](https://drevidence.com).
<a href="https://www.elastic.co/kibana/"><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4466841eed0bf232/5d082a5e97f2babb5af907ee/logo-kibana-32-color.svg" width="40" align="right"></a>
<a href="https://parceljs.org/"><img src="https://parceljs.org/avatar.633bb25a.avif" width="56" align="right"></a>
<a href="https://harperdb.io/"><img src="./assets/harperdb.png" width="55" align="right"/></a>
<a href="https://www.gatsbyjs.com/"><img src="./assets/gatsby.png" width="60" align="right"/></a>
This library is published to the NPM package `lmdb` (the 1.x versions were published to `lmdb-store`), and can be installed with:
```
npm install lmdb
```
Or in Deno can be directly used from the [deno.land `lmdb` module](https://deno.land/x/lmdb/mod.ts) (see [Deno instructions](#deno)).
This library has minimal, tightly-controlled, and maintained dependencies to ensure stability, security, and efficiency. It supports both native ESM and CJS usage.
This library was formerly known as "lmdb-store", but "lmdb-js" better represents the broad purpose of being the cross-platform LMDB JavaScript library. This package has replaced the previously deprecated (LevelDOWN) `lmdb` package in the NPM package registry, but existing versions of that library are [still available](https://www.npmjs.com/package/lmdb/v/0.2.0).
## Design
This library handles translation of JavaScript values, primitives, arrays, and objects, to and from the binary storage of LMDB keys and values with highly optimized native C++ code for breakneck performance. It supports multiple types of JS values for keys and values, making it easy to use idiomatic JS for storing and retrieving data in LMDB.
`lmdb-js` is designed for synchronous reads, and asynchronous writes. In idiomatic NodeJS and Deno code, I/O operations are performed asynchronously. LMDB is a memory-mapped database, reading and writing within a transaction does not use any I/O (other than the slight possibility of a page fault), and can usually be performed faster than the event queue callbacks can even execute, and it is easier to write code for instant synchronous values from reads. On the otherhand, commiting transactions does involve I/O, and vastly higher throughput can be achieved by batching operations and executing on a separate thread. Consequently, `lmdb-js` is designed for transactions to go through this asynchronous batching process and return a simple promise that resolves once data is written and flushed to disk.
With the default sync'ing configuration, LMDB has a crash-proof design; a machine can be turned off at any point, and data can not be corrupted unless the written data is actually changed or tampered. Writing data and waiting for confirmation that has been writted to the physical medium is critical for data integrity, but is well known to have latency (although not necessarily less efficient). However, by batching writes, when a database is under load, slower transactions enable more writes per transaction, and this library is able to drive LMDB to achieve the maximum levels of throughput with fully sync'ed operations, preserving both the durability/safety of the transactions and legendary performance.
This library supports and encourages the use of conditional writes; this allows for atomic operations that are dependendent on previously read data, and most transactional types of operations can be written with an optimistic-locking based, atomic-conditional-write pattern. This allows this library to delegate writes to off-thread execution, and scale to handle concurrent execution across many processes or threads while maintaining data integrity.
This library automatically handles automatically database growth, expanding file size with a smart heuristic that minimizes file fragmentation (as you would expect from a database).
This library provides optional compression using LZ4 that works in conjunction with the asynchronous writes by performing the compression in the same thread (off the main thread) that performs the writes in a transaction. LZ4 is extremely fast, and decompression can be performed at roughly 5GB/s, so excellent storage efficiency can be achieved with almost negligible performance impact.
## Usage
An LMDB database instance is created by using `open` export from the main module:
```
import { open } from 'lmdb'; // or require
// or in deno: import { open } from 'https://deno.land/x/lmdb/mod.ts';
let myDB = open({
path: 'my-db',
// any options go here, we can turn on compression like this:
compression: true,
});
await myDB.put('greeting', { someText: 'Hello, World!' });
myDB.get('greeting').someText // 'Hello, World!'
// or
myDB.transaction(() => {
myDB.put('greeting', { someText: 'Hello, World!' });
myDB.get('greeting').someText // 'Hello, World!'
});
```
(see database options below for more options)
Once you have opened a database, you can store and retrieve values using keys:
### Values
You can store a wide variety of JavaScript values and data structures in this library, including objects (with arbitrary complexity), arrays, buffers, strings, numbers, etc. in your database. Even full structural cloning (with cycles) is an optionally supported. Values are stored and retrieved according the database encoding, which can be set using the `encoding` property on the database options. By default, data is stored using MessagePack, but there are several supported encodings:
* `msgpack` (default) - All values are stored by serializing the value as MessagePack (using the [msgpackr](https://github.com/kriszyp/msgpackr) package). Values are decoded and parsed on retrieval, so `get` and `getRange` will return the object, array, or other value that you have stored. The msgpackr package is extremely fast
没有合适的资源?快使用搜索试试~ 我知道了~
lv-img-conv官方原版工具在lib目录生成
共2000个文件
js:12408个
ts:1711个
json:1463个
需积分: 5 2 下载量 124 浏览量
2023-01-28
09:59:17
上传
评论
收藏 71.27MB 7Z 举报
温馨提示
适配文章:富芮坤fr8008gp lvgl图片二:lv_img_conv工具的使用(脚本调用);眼瞎说明;lv_img_conv原版工具的使用(脚本调用)
资源推荐
资源详情
资源评论
收起资源包目录
lv-img-conv官方原版工具在lib目录生成 (2000个子文件)
mdb.c 355KB
mdb.c 327KB
lz4.c 105KB
lz4frame.c 80KB
lz4hc.c 69KB
xxhash.c 34KB
mdb_load.c 13KB
mdb_load.c 12KB
midl.c 8KB
midl.c 8KB
mdb_dump.c 7KB
mdb_stat.c 7KB
mdb_dump.c 7KB
mdb_stat.c 7KB
mtest_enc.c 6KB
mtest_enc2.c 6KB
mtest.c 6KB
mtest.c 6KB
mtest_remap.c 6KB
chacha8.c 5KB
mtest4.c 5KB
mtest4.c 5KB
mtest6.c 4KB
mtest6.c 4KB
mtest5.c 4KB
mtest5.c 4KB
mtest3.c 4KB
mtest3.c 4KB
crypto.c 4KB
mtest2.c 4KB
mtest2.c 4KB
mdb_drop.c 3KB
mdb_drop.c 3KB
mdb_copy.c 3KB
module.c 2KB
mdb_copy.c 2KB
windows.c 2KB
nothing.c 0B
env.cpp 35KB
misc.cpp 17KB
cursor.cpp 17KB
writer.cpp 16KB
dbi.cpp 13KB
compression.cpp 11KB
extract.cpp 9KB
txn.cpp 9KB
lmdb-js.cpp 2KB
ordered-binary.cpp 1KB
base.css 5KB
spa.css 4KB
nord.css 3KB
night-owl.css 3KB
purebasic.css 2KB
grayscale.css 2KB
atom-one-dark-reasonable.css 2KB
a11y-light.css 1KB
a11y-dark.css 1KB
gruvbox-light.css 1KB
gruvbox-dark.css 1KB
vs2015.css 1KB
isbl-editor-dark.css 1KB
shades-of-purple.css 1KB
isbl-editor-light.css 1KB
nnfx-dark.css 1KB
nnfx.css 1KB
hybrid.css 1KB
gradient-light.css 1KB
atelier-estuary-light.css 1KB
atelier-savanna-light.css 1KB
atelier-plateau-light.css 1KB
atelier-estuary-dark.css 1KB
atelier-savanna-dark.css 1KB
atelier-plateau-dark.css 1KB
atelier-cave-light.css 1KB
agate.css 1KB
gradient-dark.css 1KB
atelier-cave-dark.css 1KB
atom-one-light.css 1KB
atom-one-dark.css 1KB
routeros.css 1KB
demo.css 1KB
xcode.css 1KB
railscasts.css 1KB
an-old-hope.css 1KB
sunburst.css 1KB
idea.css 1KB
default.css 1KB
tomorrow-night-blue.css 1KB
atelier-sulphurpool-light.css 1KB
atelier-sulphurpool-dark.css 1KB
tomorrow-night.css 1KB
github.css 1KB
solarized-dark.css 1KB
solarized-light.css 1KB
docco.css 1KB
atelier-lakeside-light.css 1KB
atelier-lakeside-dark.css 1KB
pojoaque.css 1KB
atelier-seaside-light.css 1KB
atelier-seaside-dark.css 1KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
cheng@yi
- 粉丝: 61
- 资源: 15
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功