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

About opening and closing the database #197

Closed
ghost opened this issue May 27, 2021 · 6 comments
Closed

About opening and closing the database #197

ghost opened this issue May 27, 2021 · 6 comments

Comments

@ghost
Copy link

ghost commented May 27, 2021

Hey, awesome community! How u doing?

From the docs about close():

You should always clean up your levelup instance by calling close() when you no longer need it to free up resources.

and also from the docs about open():

However, it is possible to reopen the store after it has been closed with close(), although this is not generally advised.

So If I got it, I should open the database using level() to execute some operations and, as soon as possible, I should close it using close(). What about after that, when I need to execute some more operations? What is the best way to reopen it and close it again?!

@ralphtheninja
Copy link
Member

It doesn't say you should close it as soon as possible. Maybe this wording could be better.

@vweevers
Copy link
Member

Something like:

A levelup instance has associated resources like file handles and locks. When you no longer need your levelup instance (for the remainder of your program) call close() to free up resources.

@ralphtheninja
Copy link
Member

@vweevers Looks good!

@ghost
Copy link
Author

ghost commented May 28, 2021

So I should open it once and keep it open till my app don't need it anymore. Is that right?

@ralphtheninja
Copy link
Member

So I should open it once and keep it open till my app don't need it anymore. Is that right?

Correct.

@ghost
Copy link
Author

ghost commented May 28, 2021

Great! So @vweevers, that sounds good!

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