知识卡片

问题卡 · 6202.b

客户端时间比较不能解决冲突

理解等级:中级

用服务端Last-Modified和客户端Date.now比较版本,依赖不同机器时钟及时间粒度,遇到缺失或无效头还可能得到NaN。PermaNote用户选择覆盖也只是冲突策略,不提供并发写入条件校验;另一设备在读取后更新仍可能被覆盖。需要可靠版本标识和条件写入才能判断所覆盖的确是已读取版本,不能把时间戳当唯一真相。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • · 查看原书依据

      remoteModTime>localStorage.lastModified){ status("Newer note found on server."); var useit= confirm("There is a newer version of the note\n"+ "on the server.Click Ok to use that ve

    参考来源

    - 位置:《JavaScript权威指南(原书第6版)》第20章《20.4.3 离线Web应用》(spine39;extracted/OReilly精品图书系列共21册(《Javascript权威指南》、《机器学习:实用案例解析》、《编写可读代码的艺术》、《算法精解》等)/_epub-src/text/part0032.html;u472-ch20-031)。 - 结论依据:原文在“remoteModTime>localStorage.lastModified”附近的定义、例子或代码支撑本卡核心说明:用服务端Last-Modified和客户端Date.now比较版本,依赖不同机器时钟及时间粒度,遇到缺失或无效头还可能得到NaN。边界按已读前提解释;示例未执行。 - 原始内容:remoteModTime>localStorage.lastModified){ status("Newer note found on server."); var useit= confirm("There is a newer version of the note\n"+ "on the server.Click Ok to use that ve