Comparing version 2.6.0-alpha6 to 2.6.0-alpha7
@@ -45,3 +45,3 @@ import { WeakLRUCache, clearKeptObjects } from './native.js'; | ||
} | ||
get(id, cacheMode) { | ||
get(id, options) { | ||
let value; | ||
@@ -67,3 +67,3 @@ if (this.cache.validated) { | ||
} | ||
if (value && typeof value === 'object' && !cacheMode && typeof id !== 'object') { | ||
if (value && typeof value === 'object' && !options && typeof id !== 'object') { | ||
let entry = this.cache.setValue(id, value, this.lastSize >> 10); | ||
@@ -70,0 +70,0 @@ if (this.useVersions) { |
@@ -10,4 +10,5 @@ declare namespace lmdb { | ||
* @param id The key for the entry | ||
* @param options Extra settings for the get | ||
**/ | ||
get(id: K): V | undefined | ||
get(id: K, options?: {}): V | undefined | ||
/** | ||
@@ -14,0 +15,0 @@ * Get the entry stored by given id/key, which includes both the value and the version number (if available) |
40
open.js
@@ -1,2 +0,3 @@ | ||
import { Compression, getAddress, arch, fs, path as pathModule, lmdbError, EventEmitter, MsgpackrEncoder, Env, Dbi, tmpdir, os, nativeAddon } from './native.js'; | ||
import { Compression, getAddress, arch, fs, path as pathModule, lmdbError, EventEmitter, MsgpackrEncoder, Env, | ||
Dbi, tmpdir, os, nativeAddon } from './native.js'; | ||
import { CachingStore, setGetLastVersion } from './caching.js'; | ||
@@ -33,2 +34,16 @@ import { addReadMethods, makeReusableBuffer } from './read.js'; | ||
export function open(path, options) { | ||
if (nativeAddon.open) { | ||
if (nativeAddon.open !== open) { | ||
// this is the case when lmdb-js has been opened in both ESM and CJS mode, which means that there are two | ||
// separate JS modules, but they are both using the same native module. | ||
getLastVersion = nativeAddon.getLastVersion; | ||
getLastTxnId = nativeAddon.getLastTxnId; | ||
setGetLastVersion(getLastVersion, getLastTxnId); | ||
return nativeAddon.open(path, options); | ||
} | ||
} else { | ||
nativeAddon.open = open; | ||
nativeAddon.getLastVersion = getLastVersion; | ||
nativeAddon.getLastTxnId = getLastTxnId; | ||
} | ||
if (!keyBytes) // TODO: Consolidate get buffer and key buffer (don't think we need both) | ||
@@ -227,3 +242,3 @@ allocateFixedBuffer(); | ||
this.encoder = new Encoder(Object.assign( | ||
assignConstrainedProperties(['copyBuffers', 'getStructure', 'getStructures', 'saveStructure', 'saveStructures', 'useFloat32', 'useRecords', 'structuredClone', 'variableMapSize', 'useTimestamp32', 'largeBigIntToFloat', 'encodeUndefinedAsNil', 'int64AsNumber', 'onInvalidDate', 'mapsAsObjects', 'useTag259ForMaps', 'pack', 'maxSharedStructures', 'shouldShareStructure', 'randomAccessStructure', 'freezeData'], | ||
assignConstrainedProperties(['copyBuffers', 'getStructures', 'saveStructures', 'useFloat32', 'useRecords', 'structuredClone', 'variableMapSize', 'useTimestamp32', 'largeBigIntToFloat', 'encodeUndefinedAsNil', 'int64AsNumber', 'onInvalidDate', 'mapsAsObjects', 'useTag259ForMaps', 'pack', 'maxSharedStructures', 'shouldShareStructure', 'randomAccessStructure', 'freezeData'], | ||
this.sharedStructuresKey ? this.setupSharedStructures() : { | ||
@@ -350,23 +365,2 @@ copyBuffers: true, // need to copy any embedded buffers that are found since we use unsafe buffers | ||
getStructures, | ||
getStructure: (id) => { | ||
let lastVersion; // because we are doing a read here, we may need to save and restore the lastVersion from the last read | ||
if (this.useVersions) | ||
lastVersion = getLastVersion(); | ||
let buffer = this.getBinary([this.sharedStructuresKey, id]); | ||
if (this.useVersions) | ||
setLastVersion(lastVersion); | ||
return buffer; | ||
}, | ||
saveStructure: (id, structure, isCompatible) => { | ||
return this.transactionSync(() => { | ||
let key = [this.sharedStructuresKey, id]; | ||
let existingStructuresBuffer = this.getBinary(key); | ||
let existingStructures = existingStructuresBuffer && this.decoder.decode(existingStructuresBuffer); | ||
if (typeof isCompatible == 'function' ? | ||
!isCompatible(existingStructures) : | ||
(existingStructures && existingStructures.length != isCompatible)) | ||
return false; // it changed, we need to indicate that we couldn't update | ||
this.put(key, structure); | ||
}, options.overlappingSync ? 0x10000 : 0); | ||
}, | ||
copyBuffers: true, // need to copy any embedded buffers that are found since we use unsafe buffers | ||
@@ -373,0 +367,0 @@ }; |
{ | ||
"name": "lmdb", | ||
"author": "Kris Zyp", | ||
"version": "2.6.0-alpha6", | ||
"version": "2.6.0-alpha7", | ||
"description": "Simple, efficient, scalable, high-performance LMDB interface", | ||
@@ -80,3 +80,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"msgpackr": "^1.7.0-alpha2", | ||
"msgpackr": "^1.7.0-alpha5", | ||
"node-addon-api": "^4.3.0", | ||
@@ -108,9 +108,9 @@ "node-gyp-build-optional-packages": "5.0.3", | ||
"optionalDependencies": { | ||
"@lmdb/lmdb-darwin-arm64": "2.6.0-alpha6", | ||
"@lmdb/lmdb-darwin-x64": "2.6.0-alpha6", | ||
"@lmdb/lmdb-linux-arm": "2.6.0-alpha6", | ||
"@lmdb/lmdb-linux-arm64": "2.6.0-alpha6", | ||
"@lmdb/lmdb-linux-x64": "2.6.0-alpha6", | ||
"@lmdb/lmdb-win32-x64": "2.6.0-alpha6" | ||
"@lmdb/lmdb-darwin-arm64": "2.6.0-alpha7", | ||
"@lmdb/lmdb-darwin-x64": "2.6.0-alpha7", | ||
"@lmdb/lmdb-linux-arm": "2.6.0-alpha7", | ||
"@lmdb/lmdb-linux-arm64": "2.6.0-alpha7", | ||
"@lmdb/lmdb-linux-x64": "2.6.0-alpha7", | ||
"@lmdb/lmdb-win32-x64": "2.6.0-alpha7" | ||
} | ||
} |
@@ -166,3 +166,2 @@ import { RangeIterable } from './util/RangeIterable.js'; | ||
} else { | ||
console.log('should not get here', newLength) | ||
bytes = makeReusableBuffer(newLength); | ||
@@ -197,3 +196,3 @@ setGlobalBuffer(getValueBytes = bytes); | ||
let bytes = this.getBinaryFast(id, options); | ||
return bytes && (bytes == UNMODIFIED ? UNMODIFIED : this.decoder.decode(bytes)); | ||
return bytes && (bytes == UNMODIFIED ? UNMODIFIED : this.decoder.decode(bytes, options)); | ||
} | ||
@@ -607,3 +606,5 @@ if (this.encoding == 'binary') | ||
this.status = 'closing'; | ||
let txnPromise; | ||
if (this.isRoot) { | ||
// if it is root, we need to abort and/or wait for transactions to finish | ||
if (readTxn) { | ||
@@ -620,4 +621,4 @@ try { | ||
readTxnRenewed = null; | ||
txnPromise = this._endWrites && this._endWrites(); | ||
} | ||
let txnPromise = this._endWrites && this._endWrites(); | ||
const doClose = () => { | ||
@@ -624,0 +625,0 @@ if (this.isRoot) |
@@ -24,3 +24,3 @@ import { getAddress, write, compress } from './native.js'; | ||
const PROMISE_SUCCESS = Promise.resolve(true); | ||
export const ABORT = {}; | ||
export const ABORT = 4.452694326329068e-106; // random/unguessable numbers, which work across module/versions and native | ||
export const IF_EXISTS = 3.542694326329068e-103; | ||
@@ -27,0 +27,0 @@ const CALLBACK_THREW = {}; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2274529
5770
+ Added@lmdb/lmdb-darwin-arm64@2.6.0-alpha7(transitive)
+ Added@lmdb/lmdb-darwin-x64@2.6.0-alpha7(transitive)
+ Added@lmdb/lmdb-linux-arm@2.6.0-alpha7(transitive)
+ Added@lmdb/lmdb-linux-arm64@2.6.0-alpha7(transitive)
+ Added@lmdb/lmdb-linux-x64@2.6.0-alpha7(transitive)
+ Added@lmdb/lmdb-win32-x64@2.6.0-alpha7(transitive)
- Removed@lmdb/lmdb-darwin-arm64@2.6.0-alpha6(transitive)
- Removed@lmdb/lmdb-darwin-x64@2.6.0-alpha6(transitive)
- Removed@lmdb/lmdb-linux-arm@2.6.0-alpha6(transitive)
- Removed@lmdb/lmdb-linux-arm64@2.6.0-alpha6(transitive)
- Removed@lmdb/lmdb-linux-x64@2.6.0-alpha6(transitive)
- Removed@lmdb/lmdb-win32-x64@2.6.0-alpha6(transitive)
Updatedmsgpackr@^1.7.0-alpha5