Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggest: supports on-demand opening and closing #315

Open
stevobm opened this issue Nov 20, 2024 · 2 comments
Open

Suggest: supports on-demand opening and closing #315

stevobm opened this issue Nov 20, 2024 · 2 comments

Comments

@stevobm
Copy link

stevobm commented Nov 20, 2024

It will be perfect if LMDB supports on-demand opening and closing: automatically opening when the database is accessed and automatically closing when it is not in use.

@kriszyp
Copy link
Owner

kriszyp commented Nov 20, 2024

It actually already does this, automatically closing the DB on destruction in GC.

I am not sure if that aligns with what you mean by "accessed" and "not in use" though. I'm guessing you actually also want to have an API/function that can retrieve any currently-open db, if it exists, through a weak reference (that allows collection if "not in use"), and opening one otherwise (this can be done with a weakly-valued map).

@stevobm
Copy link
Author

stevobm commented Nov 30, 2024

Actually, I wish the .mdb file to be unlocked once the data is writen. Now, the file is locked until the rootDB.close() is called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants