内存数据库也有文件系统组件吗?

发布于 2024-07-28 22:24:17 字数 191 浏览 7 评论 0原文

我正在使用 Datamapper,它允许您指定系统上数据库文件的路径,或者简单地指定字符串“内存”,然后使用“内存中”数据库。 但是,我不知道这意味着什么。

“内存中”数据库是纯粹基于内存的,还是在某个时刻序列化到文件系统?

内存数据库有什么好处?

仅仅是为了提高效率 - 通过消除文件系统访问的成本吗?

I'm working with Datamapper which allows you to specify either a path to a database file on your system or simply the string "memory" and then an "in-memory" database is used. However, I have no idea what this means.

Is an "in-memory" database purely memory-based or does it get serialized to the filesystem at some point?

What's the benefit of an in-memory database?

Is it simply for efficiency - by removing the cost of filesystem access?

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

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

发布评论

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

评论(2

命硬 2024-08-04 22:24:17

SQLite 拥有内存数据库的原因并不是真的为了性能。 实际上,拥有一个文件并不比跳过它慢,除非内存不足。 它实际上主要用于临时缓存或测试。 例如,您可以使用内存数据库进行单元测试,这样您就不会遍历生产数据。 或者,如果您需要 SQL 功能,您可以使用它作为 memcache 的替代品。 基本上,它就在那里,所以如果您不需要的话,您就不必保存数据。

The reason why SQLite has in-memory databases isn't really for performance. In practice, having a file isn't really any slower than skipping that, except if you run out of memory. It's really mostly for temporary caching or testing. For instance you could use an in-memory db for your unit tests, so that you don't walk on production data. Or you could use it as an alternative to memcache if you wanted SQL functionality. Basically, it's there so you don't have to persist data, if you don't need to.

煮茶煮酒煮时光 2024-08-04 22:24:17

来自 SQLite 文档

如果文件名是“:memory:”,那么
私有、临时内存数据库
是为连接创建的。 这
内存数据库将消失
数据库连接已关闭。

From the SQLite documentation:

If the filename is ":memory:", then a
private, temporary in-memory database
is created for the connection. This
in-memory database will vanish when
the database connection is closed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文