添加文档通常是一个异步操作。这意味着当您的函数调用返回时(在您的语言特定的 SDK 上),文档并没有真正插入到 Couchbase 中。它更像是一个插入请求。
我对 CSharpDriver 知之甚少,但我可以给你一个关于 Couchbase-SDK for Java 的例子。您将不得不搜索一下将以下内容映射到您的语言。一个典型的例子是:
//Send a **request** to insert, typically spawns a new thread to poll for result.
final OperationFuture<Boolean> setOp = m_couchbaseClient.set(sKey, 0, sValue);
// More processing
//Wait on insertion. Use <FutureObject>.get()
try {
return setOp.get().booleanValue();
//when the above call returns we can be sure that insertion has happened/failed.
} catch (InterruptedException e) {
} catch (ExecutionException e) {
}