Search in sources :

Example 16 with CouchbaseEntryManager

use of io.jans.orm.couchbase.impl.CouchbaseEntryManager 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

CouchbaseEntryManager (io.jans.orm.couchbase.impl.CouchbaseEntryManager)16 Filter (io.jans.orm.search.filter.Filter)8 SimpleUser (io.jans.orm.couchbase.model.SimpleUser)5 Date (java.util.Date)5 CouchbaseEntryManagerFactory (io.jans.orm.couchbase.impl.CouchbaseEntryManagerFactory)3 CustomAttribute (io.jans.orm.model.base.CustomAttribute)3 CustomObjectAttribute (io.jans.orm.model.base.CustomObjectAttribute)3 SimpleClient (io.jans.orm.couchbase.model.SimpleClient)2 SimpleSession (io.jans.orm.couchbase.model.SimpleSession)2 SimpleSessionState (io.jans.orm.couchbase.model.SimpleSessionState)2 EntryPersistenceException (io.jans.orm.exception.EntryPersistenceException)2 List (java.util.List)2 ExecutorService (java.util.concurrent.ExecutorService)2 Test (org.testng.annotations.Test)2 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 SimpleAttribute (io.jans.orm.couchbase.model.SimpleAttribute)1 SimpleCustomStringUser (io.jans.orm.couchbase.model.SimpleCustomStringUser)1