Couchbase view results not returning with recently added document

I have a simple data package with 5 documents and adding data through a web application using the CSharp driver. ex:{'key':'Version', 'value': '1.0'}

When I request the entire list from the UI or the Couchbase console, I do not get all the results the first time, I always get the results in the second query after adding a new document. Is this the standard behavior of couchbase views? I understand that memcache is used in the background.

If this is the default behavior, then how do I handle this script? Because every application needs real-time data, or am I doing something wrong here?


I just noticed that the problem is related to production views, the above problem only occurs with the Production view not in the development view, but are there any prod views other than how this works?

+2
source share
2 answers

Try "stale = false" in the view options. Here is some documentation on index updates

+2
source

Adding a document is usually an asynchronous operation . This means that the document is not inserted into Couchbase when your function call is returned (in your SDK in your language). This is more like an insert request.

CSharpDriver, Couchbase-SDK 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) {
}
+3

All Articles