GMail API中的historyId是否保证单调递增?文件不是很清楚。
在history.list文档中,我读到了:
历史记录ID增加 按时间顺序但不与其间的随机间隙相邻 有效身份证件
这对其他API也有效,例如。 messages.list
。
我想我要问的是,总是存储historyId
我看到的最大值是否安全?
答案 0 :(得分:0)
我认为一个特定用户的消息列表的historyId
不会保证单调递增。
我检查了包含一些gmail用户元数据的数据库后。我发现没有证据显示historyId
单调增加。
以下是我的Gmail数据中historyId
和internalDate
的一部分。
> db.gmail_threads.find({integrationEmail: 'me@test.com'}, {_id:0,historyId:1, internalDate:1, date:1}).limit(500).sort({internalDate:1})
{ "historyId" : "4745", "date" : "Sun, 11 Sep 2016 02:43:52 -0700 (PDT)", "internalDate" : NumberLong("1473587032000") }
{ "historyId" : "2766", "date" : "Sun, 11 Sep 2016 02:43:57 -0700", "internalDate" : NumberLong("1473587037000") }
{ "historyId" : "2745", "date" : "Sun, 11 Sep 2016 02:43:57 -0700", "internalDate" : NumberLong("1473587037000") }
{ "historyId" : "3116", "date" : "Sun, 11 Sep 2016 02:43:57 -0700", "internalDate" : NumberLong("1473587037000") }
{ "historyId" : "2245", "date" : "Sun, 11 Sep 2016 09:44:31 +0000", "internalDate" : NumberLong("1473587071000") }
{ "historyId" : "2246", "date" : "Sun, 11 Sep 2016 09:44:58 +0000", "internalDate" : NumberLong("1473587098000") }
{ "historyId" : "2254", "date" : "Sun, 11 Sep 2016 09:57:24 +0000", "internalDate" : NumberLong("1473587844000") }
{ "historyId" : "2249", "date" : "Sun, 11 Sep 2016 09:57:31 +0000", "internalDate" : NumberLong("1473587851000") }
{ "historyId" : "2244", "date" : "Sun, 11 Sep 2016 09:57:37 +0000", "internalDate" : NumberLong("1473587857000") }
{ "historyId" : "4749", "date" : "Sun, 11 Sep 2016 09:57:58 +0000", "internalDate" : NumberLong("1473587878000") }
{ "historyId" : "2248", "date" : "Sun, 11 Sep 2016 03:10:57 -0700 (PDT)", "internalDate" : NumberLong("1473588657000") }
{ "historyId" : "3067", "date" : "Sun, 11 Sep 2016 16:21:12 -0700 (PDT)", "internalDate" : NumberLong("1473636072000") }
{ "historyId" : "3026", "date" : "Sun, 11 Sep 2016 16:33:27 -0700 (PDT)", "internalDate" : NumberLong("1473636807000") }
{ "historyId" : "2989", "date" : "Sun, 11 Sep 2016 23:38:35 +0000", "internalDate" : NumberLong("1473637115000") }
{ "historyId" : "5091", "date" : "Sun, 11 Sep 2016 16:42:52 -0700 (PDT)", "internalDate" : NumberLong("1473637372000") }
{ "historyId" : "2322", "date" : "Mon, 12 Sep 2016 01:46:21 -0000", "internalDate" : NumberLong("1473644781000") }
{ "historyId" : "3137", "date" : "Mon, 12 Sep 2016 01:53:24 -0000", "internalDate" : NumberLong("1473645204000") }
{ "historyId" : "2560", "date" : "Sun, 11 Sep 2016 20:17:09 -0700 (PDT)", "internalDate" : NumberLong("1473650229000") }
{ "historyId" : "2678", "date" : "Sun, 11 Sep 2016 22:12:18 -0700 (PDT)", "internalDate" : NumberLong("1473657138000") }
{ "historyId" : "2931", "date" : "Mon, 12 Sep 2016 12:22:54 +0000 (UTC)", "internalDate" : NumberLong("1473682974000") }
Type "it" for more
根据join
,这是限制:
历史记录通常至少提供一周且通常更长。但是,记录可用的时间段可能会少得多,并且在极少数情况下有时可能无法记录。如果客户端提供的startHistoryId超出可用的历史记录范围,则API将返回HTTP 404错误响应。在这种情况下,您的客户端必须执行完全同步,如上一节所述。