From 2d54f3f1b969a175c35c668e07b5f8d9e2a916eb Mon Sep 17 00:00:00 2001 From: Dat PHAM HOANG Date: Tue, 4 Oct 2022 17:59:06 +0700 Subject: [PATCH] TF-1010 [ADR] Guideline for Email's cache --- docs/adr/0017-email-cache-guideline.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 docs/adr/0017-email-cache-guideline.md diff --git a/docs/adr/0017-email-cache-guideline.md b/docs/adr/0017-email-cache-guideline.md new file mode 100644 index 000000000..7ecc460c3 --- /dev/null +++ b/docs/adr/0017-email-cache-guideline.md @@ -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