iam*_*der 5 android repository-pattern data-layer restful-architecture clean-architecture
I am following Clean Architecture proposed by famous Robert C. Martin. The birds eye view of Clean Architecture looks like as follows:
However right now my concern about Repository pattern modification. Basics steps of Repository pattern are:
- Search in-memory cache AND provide data to app layer
- If not found, search local data source AND sync to in-memory cache AND provide data to app layer
- 如果没有找到,搜索远程数据源并同步到本地数据源并向应用层提供数据
严格按照上述步骤操作,如果本地数据源中存在数据,它将永远不会从远程数据源同步,而数据可能会在远程更改。我该如何修改才能处理这种情况?一个想法出现在我的脑海中,写在下面,但我确实在寻找更好的解决方案。
我的想法是跟踪本地数据库中每条记录的上次同步时间。如果上次同步时间超过阈值时间,则自动同步。
| 归档时间: |
|
| 查看次数: |
1613 次 |
| 最近记录: |