TF-1839 Clean SendingEmail in cache

(cherry picked from commit 2bf35cb26095d7cebb9e722722c209878162805f)
This commit is contained in:
dab246
2023-06-05 11:42:24 +07:00
committed by Dat Vu
parent f121e0c719
commit c70a388732
4 changed files with 41 additions and 7 deletions
@@ -24,7 +24,7 @@ class SendingEmailCacheManager {
return _hiveCacheClient.insertItem(keyCache, sendingEmailHiveCache);
}
Future<List<SendingEmailHiveCache>> getAllSendingEmails(
Future<List<SendingEmailHiveCache>> getAllSendingEmailsByTupleKey(
AccountId accountId,
UserName userName,
{bool needToReopen = false}
@@ -33,7 +33,7 @@ class SendingEmailCacheManager {
accountId.asString,
userName.value,
needToReopen: needToReopen);
log('SendingEmailCacheManager::getAllSendingEmails():COUNT: ${sendingEmailsCache.length}');
log('SendingEmailCacheManager::getAllSendingEmailsByTupleKey():COUNT: ${sendingEmailsCache.length}');
sendingEmailsCache.sortByLatestTime();
return sendingEmailsCache;
}
@@ -47,4 +47,13 @@ class SendingEmailCacheManager {
log('SendingEmailCacheManager::deleteSendingEmail():keyCache: $keyCache');
return _hiveCacheClient.deleteItem(keyCache);
}
Future<List<SendingEmailHiveCache>> getAllSendingEmails() async {
final sendingEmailsCache = await _hiveCacheClient.getAll(needToReopen: true);
log('SendingEmailCacheManager::getAllSendingEmails():COUNT: ${sendingEmailsCache.length}');
sendingEmailsCache.sortByLatestTime();
return sendingEmailsCache;
}
Future<void> clearAllSendingEmails() => _hiveCacheClient.clearAllData();
}