java API/CS question

Let's say I'm adding documents to a bucket using the following API:

CouchbaseClient.set(key, 0, value);

where I only added it to the cache. My understanding is that the OperationFuture object is used to determine if the document (key/value) was successfully added to the cache. However, we have NO idea (using this API) if it was in fact successfully persisted to disk. If the OperationFuture instance indicates success, we ONLY know the document was added to the persistence queue. Now, we could use the API in which we specify to be notified when the document has been persisted, but in testing we noticed this is a much slower operation (obviously). So the question. Let's say i did the following:

Every 1000 (or some number) of set operations we use the PersistTo.ONE option. So the first 999 we used the above API, then on the 1000, we used the following:

CouchbaseClient.set(key, 0, value, PersistTo.ONE);

If I recieve a SUCCESS on the returned OperationFuture object, can I assume that the previous 999 documents have been persisted to disk?

1 Answer

« Back to question.

You cannot. The reason is that each one is distributed across the cluster. If it were just one node you could make this assumption/implication, but not if they're distributed so I wouldn't recommend this.

Since it looks like you're trying to get some parallelism, you can use the low level observe() command directly with the key and cas which are returned from the set(). If you were to do all of your set()s, collecting the key/cas, then iterate over that collection until the level of durability you want has occurred with observe(), you'll be able to get the parallelism you seek.

There is an RFE for a feature to do this for you called an ObserveSet, as covered here:
http://www.couchbase.com/issues/browse/JCBC-116