As the synchronous equivalent of db.get():
const value1 = await db.get('abc')
const value2 = db.getSync('abc')
Good to have because it's much faster. It doesn't have the overhead of scheduling asynchronous work or copying data from that thread to the JavaScript main thread. It also enables an optimization of reusing a buffer for the data transfer, knowing that only 1 thread at a time needs access to that buffer. I did a POC of that in classic-level having seen the same trick in lmdb and (although I only implemented it for keyEncoding: 'utf8') it worked rather well without adding too much complexity. The only unfortunate thing is that LevelDB's Get() method copies the data into an std::string and has no alternative API to avoid that intermediary buffer (and a double copy). Maybe it's worth a patch. The upstream code doesn't change often so I think that'd be okay.
Tasks
As the synchronous equivalent of
db.get():Good to have because it's much faster. It doesn't have the overhead of scheduling asynchronous work or copying data from that thread to the JavaScript main thread. It also enables an optimization of reusing a buffer for the data transfer, knowing that only 1 thread at a time needs access to that buffer. I did a POC of that in
classic-levelhaving seen the same trick inlmdband (although I only implemented it forkeyEncoding: 'utf8') it worked rather well without adding too much complexity. The only unfortunate thing is that LevelDB'sGet()method copies the data into anstd::stringand has no alternative API to avoid that intermediary buffer (and a double copy). Maybe it's worth a patch. The upstream code doesn't change often so I think that'd be okay.Tasks
abstract-level(3.1.0): AddgetSync()method abstract-level#114level-bench: replace the old callback-based API so we can run benchmarks againclassic-level(3.0.0): Adddb.getSync()method classic-level#120memory-level(3.1.0): Implementdb.getSync()memory-level#21browser-level: document that it's not supportedlevel(10.0.0): bump dependencies