CouchDB 文档更新处理程序会遇到更新冲突吗?
使用更新处理程序时发生修订冲突的可能性有多大?在编写强大的更新函数时,我是否应该关注冲突处理代码?
如文档更新处理程序中所述,CouchDB 0.10 及更高版本允许按需进行服务器端文档修改。
更新处理程序可以处理非 JSON 格式;但其他主要功能如下:
- 用于任意复杂文档修改代码的 HTTP 前端
- 无需为所有可能的客户端编写类似的代码 - DRY 架构
- 执行速度更快,并且不太可能遇到修订冲突
第三点我不太清楚。在本地执行,更新处理程序将运行得更快并且延迟更低。但在竞争激烈的情况下,这并不能保证更新成功。 或者更新处理程序是否保证更新成功?
How likely is a revision conflict when using an update handler? Should I concern myself with conflict-handling code when writing a robust update function?
As described in Document Update Handlers, CouchDB 0.10 and later allows on-demand server-side document modification.
Update handlers can process non-JSON formats; but the other major features are these:
- An HTTP front-end to arbitrarily complex document modification code
- Similar code needn't be written for all possible clients—a DRY architecture
- Execution is faster and less likely to hit a revision conflict
I am unclear about the third point. Executing locally, the update handler will run much faster and with lower latency. But in situations with high contention, that does not guarantee a successful update. Or does the update handler guarantee a successful update?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用更新处理程序时,仍然可能发生更新冲突。
由于“往返时间”减少,发生更新冲突的可能性较低
但不为零。冲突感觉很正常:409 响应代码
使用此 JSON:
我使用 文档更新处理程序成功触发了冲突示例,
并在壳中短时间连续运行两次curl。
其中一个curl响应(随机)是201,另一个是409。
文档更新处理程序不会从根本上改变CouchDB
更新容易发生冲突,以及验证失败(
401 Unauthorized
,403 禁止
等)Update conflicts are still possible when using update handlers.
Due to the reduced "round-trip time," the chance of an update conflict is lower
but not zero. A conflict will feel normal: a 409 response code
with this JSON:
I successfully triggered a conflict using the document update handler example,
and running curl twice in short succession in the shell.
One of the curl responses (randomly) was a 201 and the other a 409.
Document update handlers do not fundamentally change CouchDB
Updates are subject to conflicts, as well as validation failures (
401 Unauthorized
,403 Forbidden
, etc.)