如何同步HTML5本地/ webStorage和服务器端存储? [重复]

时间:2020-11-25 16:51:34

Possible Duplicate:
Best way to synchronize local HTML5 DB (WebSQL Storage, SQLite) with a server (2 way sync)

可能重复:将本地HTML5 DB(WebSQL存储,SQLite)与服务器同步的最佳方式(双向同步)

I'm currently seeking solutions for transparently and automatically synchronizing and replicating across the client-side HTML5 localStorage or web storage and (maybe multiple) server-side storage(s) (the only requirement here that it should be simple and affordable to install on a regular hosting service).

我目前正在寻求透明和自动同步和复制客户端HTML5 localStorage或Web存储和(可能是多个)服务器端存储的解决方案(这里唯一要求它应该是简单且经济实惠的安装定期托管服务)。

So do you have any experience with such libraries/technologies that offer data storage which automate the client-server storage synchronization and allow data to be available either offline or online or both? I think this is a fairly common scenario of web applications supporting offline mode...

那么您是否有使用此类库/技术的经验,这些库/技术提供数据存储自动化客户端 - 服务器存储同步并允许数据在线下或在线或两者都可用?我认为这是支持离线模式的Web应用程序的一种相当常见的场景......

4 个解决方案

#1


10  

Firebase offers this functionality as a service.

Firebase将此功能作为服务提供。

Other alternatives are:

其他替代方案是:

#2


5  

It kind of depends on what you want. There is a great tutorial to get you started at http://hacks.mozilla.org/2010/01/offline-web-applications/ Unless you want to do something complicated, you should not need that much of a framework to do it for you. I guess you could save a few lines of code on the client using jQuery. You basically want to keep in your store a record of when the last change was made to the store, when the last update was to the server, and use send the localStorage variable encoded as JSON in an XHR (or just the bit of the local store you want to send). Then, on the server, you can decode the JSON and do what you want with it, processing it or just using PHP's serialize to dump it to a database.

这取决于你想要什么。有一个很棒的教程可以帮助您入门http://hacks.mozilla.org/2010/01/offline-web-applications/除非您想要做一些复杂的事情,否则您不需要那么多的框架来完成它为你。我想你可以使用jQuery在客户端上保存几行代码。你基本上想要在你的商店中记录最后一次更改到商店的时间,最后一次更新到服务器的时间,并使用在XHR中发送编码为JSON的localStorage变量(或者只是本地的一点)你要发送的商店)。然后,在服务器上,您可以解码JSON并使用它执行所需操作,处理它或仅使用PHP的序列化将其转储到数据库。

If you have something particular in mind, do mention it.

如果您有特别的想法,请务必提及。

#3


2  

this question is rather similar.

这个问题非常相似。

There, 'quick connect' - http://quickconnect.pbworks.com/Using-Enterprise-Synchronization and my personal favorit 'persistenceJS' - https://github.com/zefhemel/persistencejs are recommended.

在那里,“快速连接” - http://quickconnect.pbworks.com/Using-Enterprise-Synchronization和我的个人青睐'persistenceJS' - 建议使用https://github.com/zefhemel/persistencejs。

As soon as I gather personal experience, I'll update this post.

一旦我收集了个人经验,我就会更新这篇文章。

#4


1  

I just found a quite new framework which does just that: Impel.inTouch. Its schema definition seems a bit inconvenient, but definitely worth a try.

我刚刚发现了一个非常新的框架:Impel.inTouch。它的架构定义似乎有点不方便,但绝对值得一试。

#1


10  

Firebase offers this functionality as a service.

Firebase将此功能作为服务提供。

Other alternatives are:

其他替代方案是:

#2


5  

It kind of depends on what you want. There is a great tutorial to get you started at http://hacks.mozilla.org/2010/01/offline-web-applications/ Unless you want to do something complicated, you should not need that much of a framework to do it for you. I guess you could save a few lines of code on the client using jQuery. You basically want to keep in your store a record of when the last change was made to the store, when the last update was to the server, and use send the localStorage variable encoded as JSON in an XHR (or just the bit of the local store you want to send). Then, on the server, you can decode the JSON and do what you want with it, processing it or just using PHP's serialize to dump it to a database.

这取决于你想要什么。有一个很棒的教程可以帮助您入门http://hacks.mozilla.org/2010/01/offline-web-applications/除非您想要做一些复杂的事情,否则您不需要那么多的框架来完成它为你。我想你可以使用jQuery在客户端上保存几行代码。你基本上想要在你的商店中记录最后一次更改到商店的时间,最后一次更新到服务器的时间,并使用在XHR中发送编码为JSON的localStorage变量(或者只是本地的一点)你要发送的商店)。然后,在服务器上,您可以解码JSON并使用它执行所需操作,处理它或仅使用PHP的序列化将其转储到数据库。

If you have something particular in mind, do mention it.

如果您有特别的想法,请务必提及。

#3


2  

this question is rather similar.

这个问题非常相似。

There, 'quick connect' - http://quickconnect.pbworks.com/Using-Enterprise-Synchronization and my personal favorit 'persistenceJS' - https://github.com/zefhemel/persistencejs are recommended.

在那里,“快速连接” - http://quickconnect.pbworks.com/Using-Enterprise-Synchronization和我的个人青睐'persistenceJS' - 建议使用https://github.com/zefhemel/persistencejs。

As soon as I gather personal experience, I'll update this post.

一旦我收集了个人经验,我就会更新这篇文章。

#4


1  

I just found a quite new framework which does just that: Impel.inTouch. Its schema definition seems a bit inconvenient, but definitely worth a try.

我刚刚发现了一个非常新的框架:Impel.inTouch。它的架构定义似乎有点不方便,但绝对值得一试。