TF-1010 [ADR] Guideline for Email's cache

This commit is contained in:
Dat PHAM HOANG
2022-10-04 17:59:06 +07:00
committed by Dat H. Pham
parent 3f51b2ea83
commit 2d54f3f1b9
+26
View File
@@ -0,0 +1,26 @@
# 17. Email cache guideline
Date: 2022-10-04
## Status
Accepted
## Context
The logic of Email cache is complicated to follow by all developers
## Decision
Brief the logic flows to easier in following the changes of cache implementation
- Email Caches of each mailbox will be filled by `ThreadConstants.defaultLimit` items at the first time open this mailbox.
- `State` of `Email` will be cached at the first time cache is filled.
- Email Caches of all mailbox will be synchronized by `Email/changes` in the case `State` of `Email` is available in local.
Only items in cache will be updated by `changes`, other will be ignored
- After any operations (CRUD with Mailbox, Email), `refreshChanges` is invoked to synchronize the cache
- To guarantee the single of truth, UI only display the final result which fetches from the cache, does not directly show the result come from the back-end
## Consequences
- Any change to `ThreadRepository::getAllEmail` and `ThreadRepository::refreshChanges` should be updated in this ADR