Add support for deleting account entities from the database.

This commit is contained in:
Jon Chambers
2020-09-22 12:06:35 -04:00
committed by Jon Chambers
parent 03ae741505
commit 86fae58c96
2 changed files with 31 additions and 0 deletions

View File

@@ -48,6 +48,7 @@ public class Accounts {
private final Timer getByUuidTimer = metricRegistry.timer(name(Accounts.class, "getByUuid" ));
private final Timer getAllFromTimer = metricRegistry.timer(name(Accounts.class, "getAllFrom" ));
private final Timer getAllFromOffsetTimer = metricRegistry.timer(name(Accounts.class, "getAllFromOffset"));
private final Timer deleteTimer = metricRegistry.timer(name(Accounts.class, "delete" ));
private final Timer vacuumTimer = metricRegistry.timer(name(Accounts.class, "vacuum" ));
private final FaultTolerantDatabase database;
@@ -134,6 +135,16 @@ public class Accounts {
}));
}
public void delete(final UUID uuid) {
database.use(jdbi -> jdbi.useHandle(handle -> {
try (Timer.Context ignored = deleteTimer.time()) {
handle.createUpdate("DELETE FROM accounts WHERE " + UID + " = :uuid")
.bind("uuid", uuid)
.execute();
}
}));
}
public void vacuum() {
database.use(jdbi -> jdbi.useHandle(handle -> {
try (Timer.Context ignored = vacuumTimer.time()) {