Get returns null for a document that I inserted

I have inserted a few documents. Then I tried to get some of the inserted documents but I always end up getting null value back.

my code is as follows.

CouchbaseClient client = ....
client.add(key, document);

client.get(key); //returns null

@srikar_nadipally, what client library are you using? and what version?

Hi @avsej,

I am using the couchbase-client for java version 1.4.5.

I think that because add() is asynchronous by default. You can call it like this to make sure that operation will complete before going to next line in your code:

client.add("hello", "world").getStatus();

@avsej is spot on, you need to call .get() on the .add() method, because it is asynchronous.
So this code will work:

 CouchbaseClient client = ....
client.add(key, document).get();

client.get(key); //returns null