get versus getAndTouch

Couchbase 2.0.1 Java client 1.1.7
We have noticed that, at times, getAndTouch, would not return our object even though we can confirm the object exists using the built-in Web Console.
By definition, getAndTouch may not return the object, perhaps, due to, among many reasons, contention ?
By definition, would get always return the object or does get have the same limitations as getAndTouch?
Thanks...

1 Answer

« Back to question.

If the item exists on the server then both get and getAndTouch will always return the item. The only difference is that with getAndTouch you can update the expiration time. Please post the code that you used to generate this issue.

The code is included at the bottom. There is only a single instance of client. I had theorized that because getAndTouch had to update the TTL, it may have failed to lock the record, perhaps, and hence, return null, but that does not seem to be the case as per your explanation.
I'd say 99% of the time the test cases would work fine, but from time to time, the test cases would fail because the session object cannot be found. The oid, a java String, does make use of characters such as "." and "_", a-z, A-Z, 0-9.
String json = null;
if(ttl > 0)
{
net.spy.memcached.CASValue casv = client.getAndTouch(oid, ttl);
if(casv != null)
json = (String)casv.getValue();
}
else
json = (String)client.get(oid);
if(json == null)
return null;

Couchbase is hosted on an i860 Windows 7 64-bit. JDK/JRE 1.7.0_21-b11 64 bit server hotspot

That code looks fine, but I was hoping that you would have posted something that had the store path in it as well so I could test it out myself. Anyways, is it possible that one of the items you were trying to get either expired or was maybe deleted by another client thread? I haven't seen anyone run into this issue before, but if you have test code I would be happy to help debug it with you.