Baseflow / Baseflow/flutter_cache_manager

Make treshold the 1 day treshold for maxObjects configurable

Aperta
#500 1 commento 3 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Dart
Stelle
809
Fork
510
Merge medio
6m
PR unite (30g)
1

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start at CacheObjectProvider.getObjectsOverCapacity and trace how the Config object currently passes maxObjects and stalePeriod into the provider. Add the optional Duration setting with a one-day default, wire it through the provider, document it alongside the related configuration options, and verify the cache respects the configured retention threshold.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
dart, flutter
Ambito
mobile-dev
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.