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

Offline capabilities when using REST (Firebase)

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

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 端点,因此您不会获得任何好处。实施您自己的客户端将是一项重大任务;它是维护数据内部视图、离线补偿、触发本地事件等的客户端代码