10000 Fix large cache size by Artiu · Pull Request #437 · tommyxchow/frosty · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 7 commits into from
Apr 7, 2025
Merged

Conversation

Artiu
Copy link
Contributor
@Artiu Artiu commented Apr 6, 2025

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 in flutter_cache_manager's database. NOT TESTED ON IOS, but I think it should be fine.

Copy link
vercel bot commented Apr 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
frostyapp ⬜️ Ignored (Inspect) Visit Preview Apr 7, 2025 2:05am

@Artiu
Copy link
Contributor Author
Artiu commented Apr 6, 2025

Fixes #434

@tommyxchow tommyxchow assigned tommyxchow and unassigned tommyxchow Apr 6, 2025
@tommyxchow tommyxchow self-requested a review April 6, 2025 23:36
Config(
key,
stalePeriod: const Duration(days: 30),
maxNrOfCacheObjects: 500,
Copy link
Owner

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.

Suggested change
maxNrOfCacheObjects: 500,
maxNrOfCacheObjects: 10000,

Copy link
Contributor Author

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.

@tommyxchow tommyxchow self-requested a review April 7, 2025 02:51
Copy link
Owner
@tommyxchow tommyxchow left a 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!

@tommyxchow tommyxchow merged commit f72614a into tommyxchow:main Apr 7, 2025
3 checks passed
@tommyxchow tommyxchow added the bug fix A fix for a bug label Apr 7, 2025
@Artiu Artiu deleted the fix-large-cache-size branch April 7, 2025 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix A fix for a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0