If I submit a cas with a non-existent key I would expect to receive CASResponse.NOT_FOUND but am receiving CASResponse.OK instead. Is this a bug? The use case is a test we created for a cas operation on either a non-existent key or a key that has expired from the cache.
Couchbase Java client 1.2.0
cas operation used: public CASResponse cas(String key, long casId, int exp, Object value
String key = UUID.randomUUID().toString();
String value = “a value”;
int documentTtl = 3600; // seconds
long cas = 0;
Update to make this a little more correct. Our test case for a key that did exist in CB and expired does properly return a CASResponse.NOT_FOUND but the case of a non-existent key is still returning OK where it should return NOT_FOUND.
Further update - I believe the OK vs NOT_FOUND is indeed a bug but it only happens when submitting a non-existent key and a cas value == 0. This is if anything a corner case that should not really ever happen as any cas retrieved from CB would be > 0.
This is arguably not the correct behavior. I don’t believe it is documented either. The documented behavior is to submit a long value for cas and if current cas != cas submitted then CASResponse.EXISTS should be returned instead of CASResponse.OK.
I just spent 30 minutes tracking down this answer… Plus one for updating Java SDK with information about CAS value == 0 being a wildcard, and the other doc to indicate that CAS value == 0 means you will never get NOT_FOUND.