How set expiry for memcached couchbase bucket documents in java

The expiry field is not populated when the document is read; it’s only used when the document is inserted/upserted. You’re not the first to be surprised by this; see: Expiry always is 0

If you experiment by setting a short expiry, I’d wager you’ll see the documents disappearing from your bucket (unless you call touch/getAndTouch).

Note that upserting clears the expiry, unless you set an expiry when upserting.