2

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

When I request back the whole list from UI or the Couchbase console, i do not get all the results on the 1st time, i always get the results on 2nd time request after adding new document. Is this the default behavior of couchbase views? I understand it uses memcache in the background.

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


I just noticed that the issue is with Production views, above mentioned issue happens only with Production views not in development view, is prod views are different than dev the way it works?

Srini
  • 708
  • 1
  • 8
  • 23

2 Answers2

3

Adding the document is an usually an asynchronous operation. This means that the document is not really inserted into the Couchbase when your function call returns (on your language specific SDK). It's more like a request for insertion.

I have little idea about CSharpDriver, but I can give you an example about Couchbase-SDK for Java. You will have to search around a bit about mapping the below to your language. A typical example is:

//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) {
}
UltraInstinct
  • 43,308
  • 12
  • 81
  • 104
  • I just noticed that the issue is with Dev view or Production view, above mentioned issue happens only with Production views, is prod views are different than dev the way it works? – Srini May 16 '13 at 18:40
2

Try the 'stale=false' in the view options. Here's some documentation about index updates

Patrick
  • 7,903
  • 11
  • 52
  • 87