lmdb
Advanced tools
Comparing version 2.9.0-alpha.1 to 2.9.0-beta.1
@@ -128,5 +128,14 @@ import { WeakLRUCache, clearKeptObjects } from './native.js'; | ||
return result; | ||
} | ||
// sync operation, immediately add to cache, otherwise keep it pinned in memory until it is committed | ||
let entry = this.cache.setValue(id, value, !result || result.isSync ? 0 : -1); | ||
} | ||
let entry; | ||
if (result?.isSync) { | ||
// sync operation, immediately add to cache | ||
if (result.result) // if it succeeds | ||
entry = this.cache.setValue(id, value, 0); | ||
else { | ||
this.cache.delete(id); | ||
return result; | ||
} // sync failure | ||
// otherwise keep it pinned in memory until it is committed | ||
} else entry = this.cache.setValue(id, value, -1); | ||
if (childTxnChanges) | ||
@@ -140,5 +149,6 @@ childTxnChanges.add(id); | ||
putSync(id, value, version, ifVersion) { | ||
let result = super.putSync(id, value, version, ifVersion); | ||
if (id !== 'object') { | ||
// sync operation, immediately add to cache, otherwise keep it pinned in memory until it is committed | ||
if (value && typeof value === 'object') { | ||
if (value && typeof value === 'object' || !result) { | ||
let entry = this.cache.setValue(id, value); | ||
@@ -150,6 +160,6 @@ if (childTxnChanges) | ||
} | ||
} else // it is possible that a value used to exist here | ||
} else // it is possible that a value used to exist here | ||
this.cache.delete(id); | ||
} | ||
return super.putSync(id, value, version, ifVersion); | ||
return result; | ||
} | ||
@@ -156,0 +166,0 @@ remove(id, ifVersion) { |
{ | ||
"name": "lmdb", | ||
"author": "Kris Zyp", | ||
"version": "2.9.0-alpha.1", | ||
"version": "2.9.0-beta.1", | ||
"description": "Simple, efficient, scalable, high-performance LMDB interface", | ||
@@ -96,2 +96,3 @@ "license": "MIT", | ||
"prebuildify-platform-packages": "5.0.4", | ||
"prettier": "^3.0.2", | ||
"rimraf": "^3.0.2", | ||
@@ -108,10 +109,14 @@ "rollup": "^2.61.1", | ||
}, | ||
"prettier": { | ||
"useTabs": true, | ||
"singleQuote": true | ||
}, | ||
"optionalDependencies": { | ||
"@lmdb/lmdb-darwin-arm64": "2.9.0-alpha.1", | ||
"@lmdb/lmdb-darwin-x64": "2.9.0-alpha.1", | ||
"@lmdb/lmdb-linux-arm": "2.9.0-alpha.1", | ||
"@lmdb/lmdb-linux-arm64": "2.9.0-alpha.1", | ||
"@lmdb/lmdb-linux-x64": "2.9.0-alpha.1", | ||
"@lmdb/lmdb-win32-x64": "2.9.0-alpha.1" | ||
"@lmdb/lmdb-darwin-arm64": "2.9.0-beta.1", | ||
"@lmdb/lmdb-darwin-x64": "2.9.0-beta.1", | ||
"@lmdb/lmdb-linux-arm": "2.9.0-beta.1", | ||
"@lmdb/lmdb-linux-arm64": "2.9.0-beta.1", | ||
"@lmdb/lmdb-linux-x64": "2.9.0-beta.1", | ||
"@lmdb/lmdb-win32-x64": "2.9.0-beta.1" | ||
} | ||
} |
@@ -19,3 +19,3 @@ [![license](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE) | ||
<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://parceljs.org/"><img src="./assets/parcel.png" width="56" align="right"></a> | ||
<a href="https://harperdb.io/"><img src="./assets/harperdb.png" width="55" align="right"/></a> | ||
@@ -345,2 +345,5 @@ <a href="https://www.gatsbyjs.com/"><img src="./assets/gatsby.png" width="60" align="right"/></a> | ||
### `db.backup(path): Promise` | ||
Safely makes a snapshot backup copy of the database at the specified target path. | ||
### `resetReadTxn(): void` | ||
@@ -347,0 +350,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). |
@@ -20,3 +20,3 @@ export const SKIP = {}; | ||
iterable.iterate = (async) => { | ||
let iterator = source[Symbol.iterator](async); | ||
let iterator = source[async ? Symbol.asyncIterator : Symbol.iterator](); | ||
let i = 0; | ||
@@ -34,2 +34,3 @@ return { | ||
if (iteratorResult.then) { | ||
if (!async) throw new Error('Can synchronously iterate with asynchronous values'); | ||
return iteratorResult.then(iteratorResult => this.next(iteratorResult)); | ||
@@ -45,2 +46,3 @@ } | ||
if (result && result.then) { | ||
if (!async) throw new Error('Can synchronously iterate with asynchronous values'); | ||
return result.then(result => | ||
@@ -75,3 +77,3 @@ result === SKIP ? | ||
[Symbol.asyncIterator]() { | ||
return this.iterator = this.iterate(); | ||
return this.iterator = this.iterate(true); | ||
} | ||
@@ -108,7 +110,8 @@ [Symbol.iterator]() { | ||
if (concatIterable.onDone) { | ||
if (result.then) | ||
if (result.then) { | ||
if (!async) throw new Error('Can synchronously iterate with asynchronous values'); | ||
result.then((result) => { | ||
if (result.done()) concatIterable.onDone(); | ||
}); | ||
else if (result.done) concatIterable.onDone(); | ||
} else if (result.done) concatIterable.onDone(); | ||
} | ||
@@ -123,3 +126,4 @@ } else { | ||
let result = iterator.next(); | ||
if (result.then) | ||
if (result.then) { | ||
if (!async) throw new Error('Can synchronously iterate with asynchronous values'); | ||
return result.then((result) => { | ||
@@ -129,2 +133,3 @@ if (result.done) return iteratorDone(result); | ||
}); | ||
} | ||
if (result.done) return iteratorDone(result); | ||
@@ -131,0 +136,0 @@ return result; |
@@ -22,3 +22,5 @@ import { getAddress, getBufferAddress, write, compress, lmdbError } from './native.js'; | ||
SYNC_PROMISE_SUCCESS.isSync = true; | ||
SYNC_PROMISE_SUCCESS.result = true; | ||
SYNC_PROMISE_FAIL.isSync = true; | ||
SYNC_PROMISE_FAIL.result = false; | ||
const PROMISE_SUCCESS = Promise.resolve(true); | ||
@@ -25,0 +27,0 @@ export const ABORT = 4.452694326329068e-106; // random/unguessable numbers, which work across module/versions and native |
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
2428310
6372
584
12