Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
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 2.0.0-alpha1 to 2.0.0-alpha2

prebuilds/win32-x64/electron.abi98.node

7

index.js

@@ -111,8 +111,3 @@ import fs from 'fs' // TODO: or Deno

}
let useWritemap = options.useWritemap
try {
env.open(options)
} catch(error) {
throw error
}
env.open(options)
env.readerCheck() // clear out any stale entries

@@ -119,0 +114,0 @@ function renewReadTxn() {

@@ -25,12 +25,2 @@ import { getAddress } from './native.js'

store.encoder = store.decoder = {
encode(value) {
if (savePosition > 6200)
allocateSaveBuffer()
let start = savePosition
savePosition = writeKey(value, saveBuffer, start)
let buffer = saveBuffer.subarray(start, savePosition)
savePosition = (savePosition + 7) & 0xfffff8
return buffer
},
decode(buffer, end) { return readKey(buffer, 0, end) },
writeKey,

@@ -40,2 +30,16 @@ readKey,

}
if (store.encoder && store.encoder.writeKey && !store.encoder.encode) {
store.encoder.encode = function(value) {
if (savePosition > 6200)
allocateSaveBuffer()
let start = savePosition
savePosition = writeKey(value, saveBuffer, start)
saveBuffer.start = start
saveBuffer.end = savePosition
savePosition = (savePosition + 7) & 0xfffff8
return saveBuffer
}
}
if (store.decoder && store.decoder.readKey && !store.decoder.decode)
store.decoder.decode = function(buffer, end) { return this.readKey(buffer, 0, end) }
if (store.keyIsUint32) {

@@ -42,0 +46,0 @@ store.writeKey = writeUint32Key

{
"name": "lmdb",
"author": "Kris Zyp",
"version": "2.0.0-alpha1",
"version": "2.0.0-alpha2",
"description": "Simple, efficient, scalable data store wrapper for LMDB",

@@ -38,5 +38,5 @@ "license": "MIT",

"prepare": "rollup -c",
"before-publish": "rollup -c && prebuildify-ci download && prebuildify --target 17.0.1 && prebuildify --target 16.9.0 && prebuildify --target 14.17.6 && prebuildify --target 12.18.0",
"prebuild": "prebuildify --target 17.0.1 && prebuildify --target 16.9.0 && prebuildify --target 14.17.6 && prebuildify --target 12.18.0",
"prebuild-arm64": "prebuildify --arch=arm64 --target 17.0.1 && prebuildify --arch=arm64 --target 16.9.0 && prebuildify --arch=arm64 --target 14.17.6",
"before-publish": "rollup -c && prebuildify-ci download && prebuildify --target 17.0.1 && prebuildify --target 16.9.0 && prebuildify --target 14.17.6 && prebuildify --target 12.18.0 && prebuildify --target electron@15.2.0",
"prebuild": "prebuildify --target 17.0.1 && prebuildify --target 16.9.0 && prebuildify --target 14.17.6 && prebuildify --target 12.18.0 && prebuildify --target electron@15.2.0",
"prebuild-arm64": "prebuildify --arch=arm64 --target 17.0.1 && prebuildify --arch=arm64 --target 16.9.0 && prebuildify --arch=arm64 --target 14.17.6 && prebuildify --arch=arm64 --target electron@15.2.0",
"recompile": "node-gyp clean && node-gyp configure && node-gyp build",

@@ -43,0 +43,0 @@ "test": "mocha test/**.test.js --recursive && npm run test:types",

[![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 version](https://img.shields.io/npm/dw/lmdb-store)](https://www.npmjs.org/package/lmdb-store)
[![get](https://img.shields.io/badge/get-8.5%20MOPS-yellow)](README.md)

@@ -356,2 +357,3 @@ [![put](https://img.shields.io/badge/put-1.7%20MOPS-yellow)](README.md)

* `overlappingSync` - This enables committing transactions where LMDB waits for a transaction to be fully flushed to disk _after_ the transaction has been committed. This option is discussed in more detail below.
* `separateFlushed` - Resolve asynchronous operations when commits are finished and visible and include a separate promise for when a commit is flushed to disk, as a `flushed` property on the commit promise.
* `eventTurnBatching` - This is enabled by default and will ensure that all asynchronous write operations performed in the same event turn will be batched together into the same transaction. Disabling this allows lmdb-store to commit a transaction at any time, and asynchronous operations will only be guaranteed to be in the same transaction if explicitly batched together (with `transactionAsync`, `batch`, `ifVersion`). If this is disabled (set to `false`), you can control how many writes can occur before starting a transaction with `txnStartThreshold` (allow a transaction will still be started at the next event turn if the threshold is not met). Disabling event turn batching (and using lower `txnStartThreshold` values) can facilitate a faster response time to write operations. `txnStartThreshold` defaults to 5.

@@ -378,3 +380,3 @@ * `encryptionKey` - This enables encryption, and the provided value is the key that is used for encryption. This may be a buffer or string, but must be 32 bytes/characters long. This uses the Chacha8 cipher for fast and secure on-disk encryption of data.

When this is enabled, there are two events of potential interest: when the transaction is committed and the data is visible (to all other threads/processes), and when the transaction is flushed and durable. For write operations, the returned promise will resolve when the transaction is committed. The promise will also have a `flushed` property that holds a second promise that is resolved when the OS reports that the transaction writes has been fully flushed to disk and are truly durable (at least as far the hardward/OS is capable of guaranteeing this). For example:
When this is enabled, there are two events of potential interest: when the transaction is committed and the data is visible (to all other threads/processes), and when the transaction is flushed and durable. When enabled, the `separateFlushed` is also enabled by default and for write operations, the returned promise will resolve when the transaction is committed. The promise will also have a `flushed` property that holds a second promise that is resolved when the OS reports that the transaction writes has been fully flushed to disk and are truly durable (at least as far the hardward/OS is capable of guaranteeing this). For example:
```

@@ -388,4 +390,6 @@ let db = open('my-db', { overlappingSync: true })

This option is probably not helpful on Windows, as Window's disk flushing operation tends to have poor performance characteristic (whereas Windows tends to perform well with standard transactions). This option may be enabled by default in the future, for non-Windows platforms.
The `separateFlushed` defaults to whatever `overlappedSync` was set to. However, you can explicitly set. If you want to use `overlappingSync`, but have all write operations resolve when the transaction is fully flushed and durable, you can set `separateFlushed` to `false`. Alternately, if you want to use different `overlappingSync` settings, but also have a `flushed` promise, you can set `separateFlushed` to `true`.
Enabling `overlappingSync` option is probably not helpful on Windows, as Window's disk flushing operation tends to have poor performance characteristic (whereas Windows tends to perform well with standard transactions), but YMMV. This option may be enabled by default in the future, for non-Windows platforms.
#### Serialization options

@@ -392,0 +396,0 @@ If you are using the default encoding of `'msgpack'`, the [msgpackr](https://github.com/kriszyp/msgpackr) package is used for serialization and deserialization. You can provide store options that are passed to msgpackr, as well. For example, these options can be potentially useful:

@@ -10,2 +10,3 @@ import path from 'path';

import { dirname } from 'path'
import { encoder as orderedBinaryEncoder } from 'ordered-binary/index.js'
let nativeMethods, dirName = dirname(fileURLToPath(import.meta.url))

@@ -62,2 +63,3 @@

//overlappingSync: true,
keyEncoder: orderedBinaryEncoder,
compression: {

@@ -64,0 +66,0 @@ threshold: 256,

@@ -11,2 +11,3 @@ import { getAddressShared as getAddress } from './native.js'

const TXN_FLUSHED = 0x20000000
const TXN_FAILED = 0x40000000
const FAILED_CONDITION = 0x4000000

@@ -25,3 +26,4 @@ const REUSE_BUFFER_MODE = 1000

var log = []
export function addWriteMethods(LMDBStore, { env, fixedBuffer, resetReadTxn, useWritemap, eventTurnBatching, txnStartThreshold, batchStartThreshold, overlappingSync, commitDelay }) {
export function addWriteMethods(LMDBStore, { env, fixedBuffer, resetReadTxn, useWritemap,
eventTurnBatching, txnStartThreshold, batchStartThreshold, overlappingSync, commitDelay, separateFlushed }) {
// stands for write instructions

@@ -52,2 +54,4 @@ var dynamicBytes

var enqueuedEventTurnBatch
if (separateFlushed === undefined)
separateFlushed = overlappingSync
var batchDepth = 0

@@ -59,3 +63,3 @@ var writeBatchStart, outstandingBatchCount

allocateInstructionBuffer()
dynamicBytes.uint32[0] = TXN_DELIMITER | TXN_COMMITTED
dynamicBytes.uint32[0] = TXN_DELIMITER | TXN_COMMITTED | TXN_FLUSHED
var txnResolution, lastQueuedResolution, nextResolution = { uint32: dynamicBytes.uint32, flagPosition: 0, }

@@ -256,3 +260,3 @@ var uncommittedResolution = { next: nextResolution }

}
if (!flushPromise && overlappingSync)
if (!flushPromise && overlappingSync && separateFlushed)
flushPromise = new Promise(resolve => flushResolvers.push(resolve))

@@ -301,4 +305,4 @@ if (writeStatus & WAITING_OPERATION) { // write thread is waiting

})
if (flushPromise)
commitPromise.flushed = flushPromise
if (separateFlushed)
commitPromise.flushed = overlappingSync ? flushPromise : commitPromise
}

@@ -311,4 +315,4 @@ return commitPromise

})
if (flushPromise)
promise.flushed = flushPromise
if (separateFlushed)
promise.flushed = overlappingSync ? flushPromise : promise
return promise

@@ -362,2 +366,3 @@ }

}
var TXN_DONE = (separateFlushed ? TXN_COMMITTED : TXN_FLUSHED) | TXN_FAILED
function resolveWrites(async) {

@@ -381,6 +386,6 @@ // clean up finished instructions

while (txnResolution &&
(instructionStatus = txnResolution.uint32[txnResolution.flagPosition] & 0x70000000)) {
if (instructionStatus & 0x40000000)
(instructionStatus = txnResolution.uint32[txnResolution.flagPosition] & TXN_DONE)) {
if (instructionStatus & TXN_FAILED)
rejectCommit()
else if (instructionStatus & TXN_COMMITTED)
else
resolveCommit(async)

@@ -387,0 +392,0 @@ }

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

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