use of io.vertx.pgclient.PgConnection in project raml-module-builder by folio-org.
the class PostgresClient method removePersistentCacheResult.
private void removePersistentCacheResult(AsyncResult<SQLConnection> conn, String cacheName, Handler<AsyncResult<Integer>> replyHandler) {
try {
if (conn.failed()) {
replyHandler.handle(Future.failedFuture(conn.cause()));
return;
}
long start = System.nanoTime();
PgConnection connection = conn.result().conn;
connection.query("DROP TABLE " + schemaName + DOT + cacheName).execute(query -> {
statsTracker("removePersistentCacheResult", "DROP TABLE " + cacheName, start);
if (query.failed()) {
replyHandler.handle(Future.failedFuture(query.cause()));
} else {
replyHandler.handle(Future.succeededFuture(query.result().rowCount()));
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
replyHandler.handle(Future.failedFuture(e));
}
}
use of io.vertx.pgclient.PgConnection in project raml-module-builder by folio-org.
the class PostgresClient method persistentlyCacheResult.
private void persistentlyCacheResult(AsyncResult<SQLConnection> conn, String cacheName, String sql2cache, Handler<AsyncResult<Integer>> replyHandler) {
try {
if (conn.failed()) {
replyHandler.handle(Future.failedFuture(conn.cause()));
return;
}
long start = System.nanoTime();
PgConnection connection = conn.result().conn;
String q = "CREATE UNLOGGED TABLE IF NOT EXISTS " + schemaName + DOT + cacheName + " AS " + sql2cache;
log.info(q);
connection.query(q).execute(query -> {
statsTracker("persistentlyCacheResult", "CREATE TABLE AS", start);
if (query.failed()) {
replyHandler.handle(Future.failedFuture(query.cause()));
} else {
replyHandler.handle(Future.succeededFuture(query.result().rowCount()));
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
replyHandler.handle(Future.failedFuture(e));
}
}
Aggregations