DATACOUCH-59 - Allow expiry touch on read
Configuration is based on Document annotation. When read of document takes place then touch action is executed on document. It is an asynchronous action so it does not block read. It is executed only on single reads (not view-based or N1QL-based ones).
This commit is contained in:
committed by
Simon Baslé
parent
90839ef604
commit
40e4212ad7
@@ -402,6 +402,22 @@ public class CouchbaseTemplateTests {
|
||||
assertEquals(versionedClass.getVersion(), foundClass.getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACOUCH-59
|
||||
*/
|
||||
@Test
|
||||
public void expiryWhenTouchOnReadDocument() throws InterruptedException {
|
||||
String id = "simple-doc-with-update-expiry-for-read";
|
||||
DocumentWithTouchOnRead doc = new DocumentWithTouchOnRead(id);
|
||||
template.save(doc);
|
||||
Thread.sleep(1500);
|
||||
assertNotNull(template.findById(id, DocumentWithTouchOnRead.class));
|
||||
Thread.sleep(1500);
|
||||
assertNotNull(template.findById(id, DocumentWithTouchOnRead.class));
|
||||
Thread.sleep(3000);
|
||||
assertNull(template.findById(id, DocumentWithTouchOnRead.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* A sample document with just an id and property.
|
||||
*/
|
||||
@@ -433,6 +449,20 @@ public class CouchbaseTemplateTests {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A sample document that expires in 2 seconds and touchOnRead set.
|
||||
*/
|
||||
@Document(expiry = 2, touchOnRead = true)
|
||||
static class DocumentWithTouchOnRead {
|
||||
|
||||
@Id
|
||||
private final String id;
|
||||
|
||||
public DocumentWithTouchOnRead(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@Document
|
||||
static class ComplexPerson {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user