Supports LRU eviction on disk cache, change the default expire type to accessDate instead of modificationDate by timonus · Pull Request #3759 · SDWebImage/SDWebImage
New Pull Request Checklist
-
I have read and understood the CONTRIBUTING guide
-
I have read the Documentation
-
I have searched for a similar pull request in the project and found none
-
I have updated this branch with the latest master to avoid conflicts (via merge from master or rebase)
-
I have added the required tests to prove the fix/feature I am adding
-
I have updated the documentation (if necessary)
-
I have run the tests and they pass
-
I have run the lint and it passes (
pod lib lint)
Pull Request Description
NSFileManager does not automatically increment access date when reading files off disk, which means that use of SDImageCacheConfigExpireTypeAccessDate is effectively identical to using SDImageCacheConfigExpireTypeCreationDate. This doesn't seem like the correct behavior on SDWebImage's part, and it isn't what's documented here. This PR makes it so that SDWebImage adjusts the file content access date when files are read off disk to address the issue.
I've also added a commit that updates the default cache behavior to SDImageCacheConfigExpireTypeAccessDate since I believe that's what's commonly expected. People generally want cache purging by time-of-use in my experience instead of using the time the file was downloaded at. If you strongly disagree I can omit that change!