TF-3385 Get & set multiple changes in email cache

This commit is contained in:
DatDang
2025-01-03 15:08:54 +07:00
committed by Dat H. Pham
parent 1ce0600c43
commit 492f4f8350
2 changed files with 58 additions and 25 deletions
@@ -95,6 +95,14 @@ class EmailCacheManager {
return _emailCacheClient.insertItem(keyCache, emailCache);
}
Future<void> storeMultipleEmails(AccountId accountId, UserName userName, List<EmailCache> emailsCache) {
return Future.wait(emailsCache.map((emailCache) => storeEmail(
accountId,
userName,
emailCache,
)));
}
Future<EmailCache> getStoredEmail(AccountId accountId, UserName userName, EmailId emailId) async {
final keyCache = TupleKey(emailId.asString, accountId.asString, userName.value).encodeKey;
final emailCache = await _emailCacheClient.getItem(keyCache, needToReopen: true);
@@ -104,4 +112,16 @@ class EmailCacheManager {
throw NotFoundStoredEmailException();
}
}
Future<List<EmailCache>> getMultipleStoredEmails(
AccountId accountId,
UserName userName,
List<EmailId> emailIds,
) async {
final keys = emailIds
.map((emailId) => TupleKey(emailId.asString, accountId.asString, userName.value).encodeKey)
.toList();
final emails = await _emailCacheClient.getValuesByListKey(keys);
return emails;
}
}