使用AngularJS和Symfony 2进行开/关线数据同步的最佳实践 [英] Best practice for on/off line data synchronization using AngularJS and Symfony 2

查看:98
本文介绍了使用AngularJS和Symfony 2进行开/关线数据同步的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在AngularJS中构建一个相对复杂且数据量很大的Web应用程序。我打算使用php作为RESTful后端(使用symfony2和FOSRESTbundle)。我花了几周时间寻找不同的线路/线路同步解决方案解决方案,似乎有很多半解决方案(参见下面的列表中的一些示例)。但他们中的任何一个似乎都完全符合我的情况。我如何决定采用哪种策略?

I'm building a relatively complex and data heavy web application in AngularJS. I'm planning to use php as a RESTful backend (with symfony2 and FOSRESTbundle). I have spent weeks looking around for different solutions to on/off line synchronization solutions and there seem to be many half solutions (see list below for some examples). But non of them seem to fit my situation perfectly. How do I go about deciding which strategy will suite me?

在AngularJS和symfony 2中构建开/关线同步系统可能决定最佳实践的问题需要一些研究,但在我的头脑中我想要考虑诸如速度,易于实现,未来证明(持久解决方案),可扩展性,客户端资源使用/需求,让多个离线用户编辑相同数据,存储多少和什么类型的数据等事​​情。

What issues that might determine "best practices" for building an on/off line synchronization system in AngularJS and symfony 2 needs some research, but on the top of my head I want to consider things like speed, ease of implementation, future proof (lasting solution), extensibility, resource usage/requirements on the client side, having multiple offline users editing the same data, how much and what type of data to store.

我目前了解的一些要求是:

Some of my requirements that I'm presently aware of are:


  • 用户将经常离线,然后需要与数据库同步(本地创建)数据

  • 多个用户共享一些可编辑数据(需要考虑潜在的合并问题)。

  • 用户可能同时从多个设备登录。

  • 允许大量数据离线存储(最高达到1 GB)

  • 我可能希望用户能够决定他想要什么本地存储。

  • 即使用户在线,我也许希望用户能够选择是使用所有(后端)数据还是仅使用本地可用的数据。

  • The users will be offline often and then needs to synchronize (locally created) data with the database
  • Multiple users share some of the editable data (potential merging issues needs to be considered).
  • User's might be logged in from multiple devices at the same time.
  • Allowing large amount of data to be stored offline(up to a gigabyte)
  • I probably want the user to be able to decide what he wants to store locally.
  • Even if the user is online I probably want the user to be able to choose whether he uses all (backend) data or only what's available locally.

一些潜在的示例解决方案

Some potential example solutions


  • PouchDB - 用于同步来自多个来源的更改的有趣策略

  • Racer - 用于实时同步的节点lib,基于ShareJS构建

  • Meteor - DDP和同步策略

  • ShareJS - Node.js运营转型,受Google Wave启发

  • Restangular - 替代$ resource

  • EmberData - EmberJS的类似ORM的数据持久性库

  • ServiceWorker

  • IndexedDB Polyfill - 使用支持WebSQL的浏览器Polyfill IndexedDB(Safari)

  • BreezeJS

  • JayData

  • Loopback的ORM

  • ActiveRecord

  • BackBone模型

  • lawnchair - 来自Brian Leroux的轻量级客户端数据库lib

  • TogetherJS - Mozilla Labs的多客户端状态同步/ collaboration lib。

  • localForage - Mozilla的DOMStorage改进库。

  • Orbit.js - 内容同步库

  • PouchDB - Interesting strategies for synchronizing changes from multiple sources
  • Racer - Node lib for realtime sync, build on ShareJS
  • Meteor - DDP and strategies for sync
  • ShareJS - Node.js operational transformation, inspired by Google Wave
  • Restangular - Alternative to $resource
  • EmberData - EmberJS’s ORM-like data persistence library
  • ServiceWorker
  • IndexedDB Polyfill - Polyfill IndexedDB with browsers that support WebSQL (Safari)
  • BreezeJS
  • JayData
  • Loopback’s ORM
  • ActiveRecord
  • BackBone Models
  • lawnchair - Lightweight client-side DB lib from Brian Leroux
  • TogetherJS - Mozilla Labs’ multi-client state sync/collaboration lib.
  • localForage - Mozilla’s DOMStorage improvement library.
  • Orbit.js - Content synchronization library

https://docs.google.com/document/d/1DMacL7iwjSMPP0ytZfugpU4v0PWUK0BT6lhyaVEmlBQ/edit#heading=h.864mpiz510wz

任何帮助都会非常感激:)

Any help would be much appreciated :)

推荐答案

你似乎想要很多东西,同步的东西很难......我正在开发一个OSS库中的一些东西的解决方案。我们的想法是它对本地数据进行版本控制,因此您可以找出已更改的内容,从而进行有意义的同步,其中还包括冲突解决等。这类似于脱机流星,因为它实际上已调整为脱机使用(对于我们没有移动数据信号的伦敦地铁)。

You seem to want a lot of stuff, the sync stuff is hard... I have a solution to some of this stuff in an OSS library I am developing. The idea is that it does versioning of local data, so you can figure out what has changed and therefore do meaningful sync, which also includes conflict resolution etc. This is sort-of the offline meteor as it is really tuned to offline use (for the London Underground where we have no mobile data signals).

我还开发了一个生态系统,包括一个连接管理器和服务器。主要项目是 https://github.com/forbesmyester/SyncIt ,并且有很好的文档和测试。该生态系统的测试应用程序将位于 https://github.com/forbesmyester/SyncItTodoMvc 但我有但是几乎没有为它编写任何文档。

I have also developed an eco system around it which includes a connection manager and server. The main project is at https://github.com/forbesmyester/SyncIt and is very well documented and tested. The test app for the ecosystem will be at https://github.com/forbesmyester/SyncItTodoMvc but I have yet to write virtually any docs for it.

它目前正在使用LocalStorage,但很容易移动到localForage,因为它实际上是使用localStorage的包装器使它成为一个异步API ...列表中的另一个可能?

It is currently using LocalStorage but will be easy to move to localForage as it actually is using a wrapper around localStorage to make it an async API... Another one for the list maybe?

这篇关于使用AngularJS和Symfony 2进行开/关线数据同步的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆