I’m in the process of updating our application from the 1.3 client to 2.0.
Leveraging information learned from the following post, with version 1.3, I was able to verify that a locally cached copy of the data retrieved from Couchbase is current by verifying that the CAS has not changed, without retrieving the often large blob of data (encoding / decoding optimization). Code that I had to do this is:
var result = CouchbaseClient.Observe(cacheKey, cachedCasValue, PersistTo.Zero, ReplicateTo.Zero);
if (result.Success && (result.Cas == cachedCasValue))
{
// MATCH - use what's in cache
} else {
// NO MATCH - cached data is out of date
}
With the new 2.0 Client, Observe has fundamentally changed; it returns an ObserveResponse object, which only contains information about data storage. It does not respect checking / verifying the CAS value. I’ve tried this:
ObserveResponse casCheck = (CouchbaseBucket.Observe(cacheKey, cachedCasValue, false, ReplicateTo.Zero, PersistTo.Zero));
And regardless of the cachedCasValue, it returns only information about Durability (in my case DurabilitySatisfied regardless of CAS value validity). Since the latest CAS is not included in the response (like in 1.3), I cannot verify this in my own code.
Is there any way to achieve the desired results with the 2.0 client? I don’t see anything in IBucket that matches, other than this method.
Thanks!
Howard