Baseflow / Baseflow/flutter_cache_manager
Make treshold the 1 day treshold for maxObjects configurable
- 主要语言
- Dart
- 星标
- 809
- 派生
- 510
- 平均合并
- 6 分钟
- 30 天内合并 PR
- 1
描述
## 🏗 Enhancement Proposal
When setting maxNrOfCacheObjects to 100 the cache can still grow above that size. This is caused by logic in the CacheObjectProvider in the getObjectsOverCapacity function.
```
where: '${CacheObject.columnTouched} < ?',
whereArgs: [
DateTime.now().subtract(const Duration(days: 1)).millisecondsSinceEpoch
],
```
From an this issue #349 I understand the reasoning behind this default value.
### Pitch
For app which are not used very intense I think the default makes sense. However for apps which use a lot of images and are used intensively throughout the day this results in a very big local cache. I've got reports of several GB.
I would argue that the there should be a parameter to override this in the Config object. This would be in line with for example the maxObjects and stalePeriod parameters.
Concretely:
- Add parameter to Config ObjectMinimumRetention (open for better naming)
- Type Duration
- Optional, default value 1 day
- Pass and use this parameter to the CacheObjectProvider
- Document
I'm happy to do a PR on this as you think this makes sense.
### Platforms affected (mark all that apply)
- [x] :iphone: iOS
- [x] :robot: Android
贡献指南
调研方向
从 CacheObjectProvider.getObjectsOverCapacity 开始,跟踪 Config 对象当前如何将 maxObjects 和 stalePeriod 传入 provider。添加可选的 Duration 设置,默认值为一天,通过 provider 传递该设置,与相关配置选项一并记录文档,并验证缓存是否遵守配置的保留阈值。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- dart, flutter
- 领域
- mobile-dev
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100