d2phap / ImageGlass

🏞 A lightweight, versatile image viewer
https://imageglass.org
Other
7.05k stars 474 forks source link

Reduce purge contention at max cache size #1908

Closed AntonyCorbett closed 1 month ago

AntonyCorbett commented 1 month ago

I found that when the DiskCache limit is reached, almost every addition to the cache results in a Purge operation (which can be quite expensive). This is because the purge operation deletes files until the cache size is just below the limit. This PR is more aggressive and reduces the cache by 50% on purge.