Baseflow / Baseflow/flutter_cache_manager

Make treshold the 1 day treshold for maxObjects configurable

Đang mở
#500 1 bình luận 3 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Dart
Star
809
Fork
510
Merge trung bình
6 phút
Pull request đã merge (30 ngày)
1

Mô tả

## 🏗 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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu từ CacheObjectProvider.getObjectsOverCapacity và truy vết cách đối tượng Config hiện truyền maxObjects và stalePeriod vào provider. Thêm thiết lập Duration tùy chọn với giá trị mặc định là một ngày, truyền thiết lập này qua provider, ghi lại tài liệu cho thiết lập cùng với các tùy chọn cấu hình liên quan và xác minh rằng cache tuân thủ ngưỡng lưu giữ đã cấu hình.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
dart, flutter
Lĩnh vực
mobile-dev
Loại issue
Tính năng
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.