Level / level

Universal abstract-level database for Node.js and browsers.
MIT License
1.55k stars 106 forks source link

About opening and closing the database #197

Closed ghost closed 3 years ago

ghost commented 3 years ago

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 commented 3 years ago

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

vweevers commented 3 years ago

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 commented 3 years ago

@vweevers Looks good!

ghost commented 3 years ago

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

ralphtheninja commented 3 years ago

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

Correct.

ghost commented 3 years ago

Great! So @vweevers, that sounds good!