kriszyp / lmdb-js

Simple, efficient, ultra-fast, scalable data store wrapper for LMDB
Other
482 stars 39 forks source link

Memory only option? #123

Closed Darkle closed 2 years ago

Darkle commented 2 years ago

Hi, I'm currently writing tests for my project which uses both sqlite and lmdb.

The sqlite3 module has a feature where you can set it to be a "memory-only" database, which is very handy for testing and I was wondering if lmdb-js had that feature as well?

kriszyp commented 2 years ago

No, sorry, there is no current option for that. Theoretically it seems feasible; I believe both Posix and Win32 both provide non-persisted memory maps. But the closest thing to that now is using noSync (and possibly writeMap), so at least you don't have to have wait for any disk I/O, and then deleting the db after (or before) the tests (which is what I do in the lmdb-js tests). I wonder if it would help to have a setting for temporary databases that would auto-generate a name in the current temp directory and auto-delete on close (and use noSync)? Of course that does still involve the file system though.

kriszyp commented 2 years ago

V2.2.0 now has support for "temporary" databases which should hopefully provide a convenient way to create databases for testing: https://github.com/DoctorEvidence/lmdb-js/releases/tag/v2.2.0