Couchbase .NET客户端库GetView缓存问题缓存、客户端、问题、Couchbase

2023-09-06 17:27:25 作者:骚与矜持并存

我跑couchbase服务器2.0(DEV preVIEW 4),并使用.NET客户端库1.2版。

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

在我的一些文档(JSON)添加到我的数据库,然后在几秒钟内(小于10),我试图通过.NET客户端库获得通过GetView这份文件,它总是返回旧值的第一个查询。只有在第二个查询返回的实际值。

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.

当我Exec的通过REST API相同的查询,它返回的实际值。

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

任何人都可以提供有关这方面的一些信息?

Can anyone provide some information about this?

推荐答案

的意见Couchbase的默认行为是更新索引视图增量。它要求一种观点认为,实际上触发了增量更新。换句话说,当所请求的视图中的第一次,你触发要更新的服务器上的索引(唯一的新文件需要被索引)。因此,新的文件(S)是由一次收录到您对GetVew第二个电话。

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.

在这种方式,Couchbase视图是最终一致。如果旧读不适合或可以容忍你的情况,你可以当你要求查看和修改默认行为使用陈旧流利的方法。

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);

一些更多的信息,请访问 HTTP: //www.couchbase.com/docs/couchbase-sdk-net-1.2/api-reference-view.html 。

约翰 -