Код: Выделить всё
Instant threshold = Instant.now().minus(retention);
String query = String.format("delete from %s.%s.%s where _lastmodified < \"%s\"", bucketName, scopeName, collectionName, threshold);
QueryResult result = cluster.query(query);
Код: Выделить всё
Instant threshold = Instant.now().minus(retention);
String query = String.format("delete from %s.%s.%s where _lastmodified < \"%s\"", bucketName, scopeName, collectionName, threshold);
ReactiveCluster rc = couchbase.reactive();
try {
rc.query(query,
QueryOptions.queryOptions()
.readonly(true)
.scanConsistency(QueryScanConsistency.REQUEST_PLUS)
.metrics(true)
).flux().flatMap(result -> {
Flux rows = result.rowsAs(JsonObject.class);
return rows;
}).subscribe(row -> {
// process one row
}, (Throwable t) -> {
log.error("Could not read data", t);
}
);
} finally {
rc.disconnect();
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... -async-api
Мобильная версия