Create a write-through cache for PendingRetryReceiptDatabase.

This commit is contained in:
Greyson Parrelli
2021-07-01 12:56:25 -04:00
committed by Alex Hart
parent 0921ebe5f1
commit 62040d06b4
9 changed files with 152 additions and 34 deletions

View File

@@ -232,7 +232,7 @@ public final class MessageContentProcessor {
}
RecipientId senderId = RecipientId.fromHighTrust(content.getSender());
PendingRetryReceiptModel pending = DatabaseFactory.getPendingRetryReceiptDatabase(context).get(senderId, content.getTimestamp());
PendingRetryReceiptModel pending = ApplicationDependencies.getPendingRetryReceiptCache().get(senderId, content.getTimestamp());
long receivedTime = handlePendingRetry(pending, content);
log(String.valueOf(content.getTimestamp()), "Beginning message processing.");
@@ -350,7 +350,7 @@ public final class MessageContentProcessor {
if (pending != null) {
warn(content.getTimestamp(), "Pending retry was processed. Deleting.");
DatabaseFactory.getPendingRetryReceiptDatabase(context).delete(pending.getId());
ApplicationDependencies.getPendingRetryReceiptCache().delete(pending);
}
} catch (StorageFailedException e) {
warn(String.valueOf(content.getTimestamp()), e);

View File

@@ -147,7 +147,7 @@ public final class MessageDecryptionUtil {
break;
case RESENDABLE:
Log.w(TAG, "[" + envelope.getTimestamp() + "] Inserting into pending retries store because it's " + contentHint);
DatabaseFactory.getPendingRetryReceiptDatabase(context).insert(sender.getId(), senderDevice, envelope.getTimestamp(), receivedTimestamp, threadId);
ApplicationDependencies.getPendingRetryReceiptCache().insert(sender.getId(), senderDevice, envelope.getTimestamp(), receivedTimestamp, threadId);
ApplicationDependencies.getPendingRetryReceiptManager().scheduleIfNecessary();
break;
case IMPLICIT: