Socket
Socket
Sign inDemoInstall

lmdb

Package Overview
Dependencies
Maintainers
3
Versions
174
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lmdb - npm Package Compare versions

Comparing version 1.6.6 to 1.6.7

assets/performance.png

4

package.json
{
"name": "lmdb",
"author": "Kris Zyp",
"version": "1.6.6",
"version": "1.6.7",
"description": "Simple, efficient, scalable data store wrapper for LMDB",

@@ -48,3 +48,3 @@ "license": "MIT",

"devDependencies": {
"@types/node": "latest",
"@types/node": "^16.7.10",
"benchmark": "^2.1.4",

@@ -51,0 +51,0 @@ "chai": "^4.3.4",

@@ -16,2 +16,4 @@ [![license](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE)

<a href="https://github.com/kriszyp/db-benchmark"><img src="./assets/performance.png" width="700"/></a>
Benchmarking on Node 14.9, with 3.4Ghz i7-4770 Windows, a get operation, using JS numbers as a key, retrieving data from the database (random access), and decoding the data into a structured object with 10 properties (using default [MessagePack encoding](https://github.com/kriszyp/msgpackr)), can be done in about half a microsecond, or about 1,900,000/sec on a single thread. This is almost three times as fast as a single native `JSON.parse` call with the same object without any DB interaction! LMDB scales effortlessly across multiple processes or threads; over 6,000,000 operations/sec on the same 4/8 core computer by running across multiple threads (or 18,000,000 operations/sec with raw binary data). By running writes on a separate transactional thread, writing is extremely fast as well. With encoding the same objects, full encoding and writes can be performed at about 500,000 puts/second or 1,700,000 puts/second on multiple threads.

@@ -224,3 +226,3 @@

### `store.openDB(database: string|{name:string,...})`
LMDB supports multiple databases per environment (an environment is a single memory-mapped file). When you initialize an LMDB store with `open`, the store uses the default root database. However, you can use multiple databases per environment/file and instantiate a store for each one. If you are going to be opening many databases, make sure you set the `maxDbs` (it defaults to 12). For example, we can open multiple stores for a single environment:
LMDB supports multiple databases per environment (an environment corresponds to a single memory-mapped file). When you initialize an LMDB store with `open`, the store uses the default root database. However, you can use multiple databases per environment/file and instantiate a store for each one. If you are going to be opening many databases, make sure you set the `maxDbs` (it defaults to 12). For example, we can open multiple stores for a single environment:
```

@@ -239,3 +241,3 @@ const { open } = require('lmdb');

Both these puts will be batched and committed in the same transaction in the next event turn.
Also, you can start a transaction from one store and make writes from any of the stores in that same environment (and they will be a part of the same transaction:
Also, you can start a transaction from one store and make writes from any of the stores in that same environment (and they will be a part of the same transaction):
```

@@ -257,2 +259,8 @@ rootStore.transactionAsync(() => {

### `store.getBinary(key): Buffer`
This will retrieve the binary data at the specified key. This is just like `get`, except it will always return the value's binary representation as a buffer, rather than decoding with the store's encoding format (if there is no entry, `undefined` will still be returned).
### `store.getBinaryFast(key): Buffer`
This will retrieve the binary data at the specified key, like `getBinary`, except it uses reusable buffers, which is faster, but means the data in the buffer is only valid until the next get operation (including cursor operations).
### `resetReadTxn(): void`

@@ -259,0 +267,0 @@ Normally, this library will automatically start a reader transaction for get and range operations, periodically reseting the read transaction on new event turns and after any write transactions are committed, to ensure it is using an up-to-date snapshot of the database. However, you can call `resetReadTxn` if you need to manually force the read transaction to reset to the latest snapshot/version of the database. In particular, this may be useful running with multiple processes where you need to immediately reset the read transaction based on a known update in another process (rather than waiting for the next event turn).

@@ -427,2 +427,8 @@ 'use strict';

count.should.equal(2);
});
it('should count ordered-binary dupsort query with start/end', async function() {
db3.put('key1', 1);
db3.put('key1', 2);
db3.put('key1', 3);
await db3.put('key2', 3);
db3.getValuesCount('key1').should.equal(3);

@@ -437,2 +443,49 @@ db3.getValuesCount('key1', { start: 1, end: 3 }).should.equal(2);

});
it('should reverse iterate ordered-binary dupsort query with start/end', async function() {
db3.put('key1', 1);
db3.put('key1', 2);
db3.put('key1', 3);
await db3.put('key2', 3);
let count = 0;
for (let value of db3.getValues('key1', { reverse: true, start: 2 })) {
count++;
value.should.equal(3 - count);
}
count.should.equal(2);
count = 0;
for (let value of db3.getValues('key1', { reverse: true, start: 2.5 })) {
count++;
value.should.equal(3 - count);
}
count.should.equal(2);
count = 0;
for (let value of db3.getValues('key1', { reverse: true, start: 50 })) {
count++;
value.should.equal(4 - count);
}
count.should.equal(3);
count = 0;
for (let value of db3.getValues('key1', { reverse: true, start: 2, end: 1 })) {
count++;
value.should.equal(3 - count);
}
count.should.equal(1);
count = 0;
for (let value of db3.getValues('key1', { reverse: true, end: 1 })) {
count++;
value.should.equal(4 - count);
}
count.should.equal(2);
count = 0;
for (let value of db3.getValues('key1', { reverse: true, start: 0.5 })) {
count++;
}
count.should.equal(0);
});
it('doesExist', async function() {

@@ -559,3 +612,3 @@ let data1 = {foo: 1, bar: true}

});
it.skip('big child transactions', async function() {
it('big child transactions', async function() {
let ranTransaction

@@ -567,8 +620,5 @@ db.put('key1', 'async initial value'); // should be queued for async write, but should put before queued transaction

let value
for (let i = 0; i < 4; i++) {
value += ' test string ' + value
for (let i = 0; i < 5000; i++) {
db.put('key' + i, 'test')
}
for (let i = 0; i < 4000; i++) {
db.put('key' + i, value)
}
})

@@ -575,0 +625,0 @@ await db.put('key1', 'test');

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc