Search in sources :

Example 1 with SubdocOptionsBuilder

use of com.couchbase.client.java.subdoc.SubdocOptionsBuilder in project jans by JanssenProject.

the class ManualCouchbaseEntryManagerTest method sampleSessionId.

// manual
@Test(enabled = false)
public void sampleSessionId() throws IOException, SearchException {
    CouchbaseEntryManager manager = createCouchbaseEntryManager();
    try {
        SessionId sessionId = createSessionId();
        manager.persist(sessionId);
        final String key = "sessions_" + sessionId.getId();
        System.out.println("Key: " + key + ", ttl:" + sessionId.getTtl());
        Bucket sessionBucket = manager.getOperationService().getConnectionProvider().getBucketMapping("sessions").getBucket();
        final JsonDocument lookup = sessionBucket.get(key);
        System.out.println("expiry: " + lookup.expiry());
        DocumentFragment<Lookup> ttl = sessionBucket.lookupIn(key).get("$document.exptime", new SubdocOptionsBuilder().xattr(true)).execute();
        System.out.println("ttl: " + ttl.content("$document.exptime"));
        updateSession(sessionId);
        manager.merge(sessionId);
        final JsonDocument lookup2 = manager.getOperationService().getConnectionProvider().getBucketMapping("sessions").getBucket().get(key);
        System.out.println("expiry after update: " + lookup2.expiry());
    } finally {
        manager.destroy();
    }
}
Also used : SubdocOptionsBuilder(com.couchbase.client.java.subdoc.SubdocOptionsBuilder) Bucket(com.couchbase.client.java.Bucket) CouchbaseEntryManager(io.jans.orm.couchbase.impl.CouchbaseEntryManager) Lookup(com.couchbase.client.core.message.kv.subdoc.multi.Lookup) JsonDocument(com.couchbase.client.java.document.JsonDocument) Test(org.testng.annotations.Test)

Aggregations

Lookup (com.couchbase.client.core.message.kv.subdoc.multi.Lookup)1 Bucket (com.couchbase.client.java.Bucket)1 JsonDocument (com.couchbase.client.java.document.JsonDocument)1 SubdocOptionsBuilder (com.couchbase.client.java.subdoc.SubdocOptionsBuilder)1 CouchbaseEntryManager (io.jans.orm.couchbase.impl.CouchbaseEntryManager)1 Test (org.testng.annotations.Test)1