基于时间戳的同步,如何降低移动数据使用 [英] Timestamp based sync, how to reduce the mobile data usage

查看:119
本文介绍了基于时间戳的同步,如何降低移动数据使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我现在该怎么执行同步:

This is how I perform a sync now:

 * get preference "timestamp" and save to variable TIMESTAMP
 * save current time to preference "timestamp"      (2)
 * query server side items with update time bigger than TIMESTAMP
 * for each item
 *      compare with local item's per item update_time
 *      if server side is newer
 *          update local
 *      else if local is newer
 *          set item update time to now             (1)
 *          upload
 *          save back
 *      else if equal
 *          do nothing
 * 

现在的问题是,当我同步下一次,最后一次同步的项目将出现在做什么一节中,但我的应用程序是一个移动应用程序,所以有一个大的数据的浪费。

The question is, when I sync next time, the last time synced items will appear in the "do nothing" section, but my app is a mobile app, so there is a large data waste.

我认为项目的更新时间大约设置为 TIMESTAMP ,但我觉得有这样的情况有两个客户端同步的同时,也有不同步的机会,由于该项目的实际上传的时间是不是它有什么更新时间字段,如果一个客户端检查这两个时间之间的服务器上,该项目错过了。

I thought about set the items's update time to TIMESTAMP, but I think there are situations that two client is syncing the same time, and there are chance of out sync, because the item's real uploaded time is not what in it's update time field, and if one client checked the server between the two time, this item is missed.

我使用谷歌API的任务,我不能改变服务器端的实现。

I'm using Google Tasks API, I cannot change the implement of the server side.

有什么建议?

推荐答案

与时间戳,否则可能会导致一些问题,是由于timezones.Perhaps定义一个ID为服务器端的更新和目前的最大数据版本ID与比较你的应用程序服务器可以更加可靠和有效的

Doing this with timestamp may be cause some problems due to timezones.Perhaps defining an id for updates of server side and comparing your apps current max data version id with server's can be more reliable and efficient

这篇关于基于时间戳的同步,如何降低移动数据使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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