本地 GAE 在运行时是否会读取和写入硬盘驱动器上的本地数据存储文件?

发布于 2024-10-28 04:38:18 字数 308 浏览 5 评论 0原文

我刚刚注意到,当我有一个正在运行的 GAE 应用程序实例时,当我使用 Python 代码或在管理控制台中添加或删除条目时,数据存储文件没有任何反应。我什至可以删除该文件,并且所有数据仍然安全无误地保存在管理区域中,并且可以通过代码访问。但是,当我重新启动应用程序时,所有数据显然都会消失,并且我有一个空白的数据存储。那么,问题是 - GAE 是否仅在启动时从文件中读取所有数据,然后在内存中处理它,并在我停止应用程序后保存数据?当应用程序运行时,它是否向数据存储文件发出任何请求?如果它在运行时不向文件保存任何内容,那么如果应用程序意外停止,数据可能会丢失?如果你知道这方面是如何运作的,请给我说清楚。

I have just noticed that when I have a running instance of my GAE application, there nothing happens with the datastore file when I add or remove entries using Python code or in admin console. I can even remove the file and still have all data safe and sound in admin area and accessible from code. But when I restart my application, all data obviously goes away and I have a blank datastore. So, the question - does GAE reads all data from the file only when it starts and then deals with it in the memory, saving the data after I stop the application? Does it make any requests to the datastore file when the application is running? If it doesn't save anything to the file while it's running, then, possibly, data may be lost if the application unexpectedly stops? Please make it clear for me if you know how it works in this aspect.

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

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

发布评论

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

评论(2

温柔女人霸气范 2024-11-04 04:38:18

数据存储读取和写入其底层文件的方式各不相同 - 标准数据存储在启动时读取,并在应用程序修改数据时以日志方式逐步写入。 SQLite 后端使用 SQLite 数据库。

不过,您不必关心 - 这两个后端都不是为面对故障时的鲁棒性而设计的,因为它们是开发后端。您也不应该修改或删除底层文件。

How the datastore reads and writes its underlying files varies - the standard datastore is read on startup, and written progressively, journal-style, as the app modifies data. The SQLite backend uses a SQLite database.

You shouldn't have to care, though - neither backend is designed for robustness in the face of failure, as they're development backends. You shouldn't be modifying or deleting the underlying files, either.

微暖i 2024-11-04 04:38:18

默认情况下,dev_appserver 会将其数据存储在临时位置(这就是它消失并且您看不到任何更改的原因)

如果您不希望数据在重新启动时消失,请设置--datastore_path 当运行您的开发服务器时,如下所示:

dev_appserver.py --datastore_path /path/to/app/myapp.db /path/to/app

正如 nick 所说,开发服务器并不是为了防弹而构建的,它旨在帮助您快速开发应用程序。生产设置非常不同,当您处理特殊情况时,不会出现任何意外情况。

By default the dev_appserver will store it's data in a temporary location (which is why it disappears and you can't see anything changing)

If you don't want your data to disappear on restart set --datastore_path when running your dev server like:

dev_appserver.py --datastore_path /path/to/app/myapp.db /path/to/app

As nick said, the dev server is not built to be bulletproof, it's designed to help you quickly develop your app. The production setup is very different and will not do anything unexpected when you are dealing with exceptional circumstances.

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