Couchbase .Net client library GetView caching issue

孤街浪徒 提交于 2019-12-11 03:29:01

问题


I'm running couchbase server 2.0 (dev preview 4) and using .net client library version 1.2.

When I add some document (json) to my database and then in few seconds (less then 10) I try to get this document via GetView through .net client library and it always returns old value on first query. Only on second query it returns actual value.

When I exec same query through REST api, it returns actual value.

Can anyone provide some information about this?


回答1:


The default behavior of views in Couchbase is to update the index for a view incrementally. It's requesting a view that actually triggers the incremental update. In other words, when you requested the view the first time, you triggered the index to be updated on the server (only new documents need to be indexed). So the new document(s) was indexed by the time you made the second call to GetVew.

In this way, Couchbase views are eventually consistent. If a stale read is not appropriate or tolerable for your situation, you could use the Stale fluent method when you request the view and modify the default behavior.

So to force the view to be updated before getting results:

var view = client.GetView("beers", "by_name").Stale(StaleMode.False);

Some more info is available at http://www.couchbase.com/docs/couchbase-sdk-net-1.2/api-reference-view.html.

-- John



来源:https://stackoverflow.com/questions/11296815/couchbase-net-client-library-getview-caching-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!