gpt4 book ai didi

c++ - 使用 REST (Firebase) 时的离线功能

转载 作者:行者123 更新时间:2023-11-28 00:13:30 25 4
gpt4 key购买 nike

所以我在文档中找到了这个:

Every client sharing a Firebase maintains its own internal version of any active data. When data is updated or saved, it is written to this local version of the Firebase. The Firebase client then synchronizes that data with the Firebase servers and with other clients on a 'best-effort' basis.

As a result, all writes to Firebase will trigger local events immediately, before any data has even been written to the server. This means the app will remain responsive regardless of network latency or Internet connectivity.

Once connectivity is reestablished, we'll receive the appropriate set of events so that the client "catches up" with the current server state, without having to write any custom code.

是的,我明白了,但更具体地说(我无法找到答案):

我在 c++ 程序中使用 REST-API,它执行 curl-请求。到目前为止一切正常。对于插入,这没什么大不了的。如果出现错误,我可以轻松地通过 redis 或其他方式存储数据并在以后更新它们,但是读取是如何工作的?

给你一个场景:

我制作了一个扫描仪,可以识别 ID。在此过程之后,它被插入(如上所述)到 Firebase 中。人们还可以在相关主页上注册(并手动插入他们的 ID)。这也将保存在 Firebase 中。显然是同一个节点。

Firebase 旨在通过访问数据库将数据从一个端点提供到另一个端点,这很好。用户在网站上注册并被插入到数据库中。突然间,我的互联网连接中断了。

在我的连接消失之前,有没有办法获取最后使用的“堆栈”或“完整数据集”?有没有办法复制数据库和队列作业,这些作业将在重新建立连接后同步?

最佳答案

免责声明:我为 Firebase 工作。

您在上面引用的段落具体指的是我们维护的客户端库(目前在 Objective-C、Java 和 JavaScript 中)- 这些是我们编写的代码片段,您将在您的应用程序中运行。

在这种情况下,您没有特别使用客户端库 - 您只是访问了我们的常规 REST 端点,因此您不会获得任何好处。实现您自己的客户端将是一项重大任务;它是维护数据内部 View 、在离线时进行补偿、触发本地事件等的客户端代码。

关于c++ - 使用 REST (Firebase) 时的离线功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31856258/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com