5

It seems like the document expiry value is always retrieved as "0" by the couchbase client, although obviously it is taken into account. Any ideas ? (Using couchbase Java Client 2.2.8)

bucket.upsert(JsonDocument.create(key, 5, content));

    try {
        for (int i = 0; i < 10; i++) {
            Thread.sleep(1000);             
            print("expiry :" + bucket.get(key).expiry());
        }
    } catch (NullPointerException e) {
        print("Document Expired");
    }

Code Output :

expiry :0
expiry :0
expiry :0
expiry :0
expiry :0
Document Expired

Mehdi LAMRANI
  • 11,289
  • 14
  • 88
  • 130

2 Answers2

2

An expiry value of 0 means that there is no expiration set for the document. If there is an expiration set then the number will correspond to the unix time that the document is supposed to expire.

mikewied
  • 5,273
  • 1
  • 20
  • 32
  • the first line `JsonDocument.create(key, 5, content)` sets document expiry to 5 seconds, and indeed, as the code output suggest the document is deleted from the database after that amount of time. However, the expiry field returns 0 all the time, hence my question – Mehdi LAMRANI Jul 24 '17 at 21:35
0

See comment in Couchbase Forum post

Yes, this is expected and not a bug since the get call underneath from the server doesn’t return the expiration time.

I think it is strange (indeed a bug) since the SDK documentation makes me believe Java client can read the document expiry....

AChoice
  • 558
  • 5
  • 8