Skip to content

Commit 46a89f6

Browse files
authored
Merge pull request #82 from eclipse/couchbase-ttl-fix
Couchbase ttl fix
2 parents e754f19 + c634c6e commit 46a89f6

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

couchbase-driver/src/main/java/org/jnosql/diana/couchbase/document/DefaultCouchbaseDocumentCollectionManager.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
import static java.util.Objects.nonNull;
4040
import static java.util.Objects.requireNonNull;
41-
import static java.util.concurrent.TimeUnit.MILLISECONDS;
4241
import static java.util.stream.Collectors.toSet;
4342
import static org.jnosql.diana.couchbase.document.EntityConverter.ID_FIELD;
4443
import static org.jnosql.diana.couchbase.document.EntityConverter.KEY_FIELD;
@@ -81,7 +80,7 @@ public DocumentEntity insert(DocumentEntity entity, Duration ttl) {
8180

8281
String prefix = getPrefix(id, entity.getName());
8382
jsonObject.put(KEY_FIELD, prefix);
84-
bucket.upsert(JsonDocument.create(prefix, jsonObject), ttl.toMillis(), MILLISECONDS);
83+
bucket.upsert(JsonDocument.create(prefix, (int) ttl.getSeconds(), jsonObject));
8584
return entity;
8685
}
8786

couchbase-driver/src/test/java/org/jnosql/diana/couchbase/document/CouchbaseDocumentCollectionManagerAsyncTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void shouldInserAsyncTTL() throws InterruptedException {
9898
Document id = entity.find("name").get();
9999
DocumentQuery query = select().from(COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
100100
List<DocumentEntity> entities = entityManager.select(query);
101-
assertFalse(entities.isEmpty());
101+
assertTrue(entities.isEmpty());
102102

103103
}
104104

@@ -115,7 +115,7 @@ public void shouldInserAsyncCalbackTTL() throws InterruptedException {
115115
Document id = entity.find("name").get();
116116
DocumentQuery query = select().from(COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
117117
List<DocumentEntity> entities = entityManager.select(query);
118-
assertFalse(entities.isEmpty());
118+
assertTrue(entities.isEmpty());
119119

120120
}
121121

0 commit comments

Comments
 (0)