在我的应用程序运行期间保持嵌入式数据库文件打开可以吗?

发布于 2024-08-24 01:53:52 字数 101 浏览 2 评论 0原文

我正在使用嵌入式数据库文件,在启动我的应用程序时,我将打开数据库文件,只有当应用程序退出时,我才会关闭数据库文件,这是最佳实践吗?

我应该使用传统的打开-更新-关闭方式吗?

I am using an embedded database file, on start up of my app, i will open the database file, only when the app exit, i close the database file, is it a best practice?

should i use it the traditional open-update-close fashion?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

熟人话多 2024-08-31 01:53:52

这种方法没有任何问题,只要:

  • 数据库不共享
  • 保持连接打开不需要大量资源
  • 当应用程序崩溃或意外终止时,您可以安全地释放任何分配的资源。

There's nothing wrong with this approach as long as:

  • the database isn't shared
  • keeping an connection open does not require significant resources
  • you can safely release any allocated resources when your application crashes or terminates unexpectedly.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文