-
-
Notifications
You must be signed in to change notification settings - Fork 49
Fix large cache size #437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix large cache size #437
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
Fixes #434 |
lib/cache_manager.dart
Outdated
Config( | ||
key, | ||
stalePeriod: const Duration(days: 30), | ||
maxNrOfCacheObjects: 500, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
500 for maxNrOfCacheObjects
seems too small, considering there can be hundreds of emotes and/or badges for each channel.
What do you think about 10,000? Seems like a good number to start with based on my rough estimate here: considering a 1GB image cache limit, if we assume an emote size of 100kb, 1,000,000 KB / 100 KB = 10,000 emotes. 7TV 4x emotes seem to be around 10-30 kb while GIFs are around 100-300 kb.
maxNrOfCacheObjects: 500, | |
maxNrOfCacheObjects: 10000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right, 500 is too small. I mean the most important part is clearing images which wasn't used for more than 30 days.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested it on my iPhone and it looks like it works on iOS too - went from ~4GB to ~700 MB after launch.
Nice work and thank you again!
There's big problem with caching images in disk (cache on my release app exceeded 4GB). I find out that it's problem with caching library working under the hood of
cached_network_image
package (flutter_cache_manager
).flutter_cache_manager
is only clearing cache from files database, not from file system. So I fixed this in this PR by adding function to remove images which are not influtter_cache_manager
's database. NOT TESTED ON IOS, but I think it should be fine.