ios – Understanding Memory and Disk Cache Usage in Kingfisher or SDWebImage’s Image Cache

[ad_1]

I am learning how to use Kingfisher’s cache to better understand caching mechanisms. I see that Kingfisher uses two types of cache: MemoryCache (which uses NSCache) and DiskCache (which uses FileManager to save files). Both types of cache are declared in ImageCache. However, I am a bit confused about how ImageCache works. Specifically, I have the following questions:

  • Does ImageCache in Kingfisher use memory or disk cache by default? Do they use a combination of both, or just one of the two? If they use a combination of both, what is the mechanism – When the memory cache is full, it will switch to the disk cache?
  • The two types of caches (MemoryCache and DiskCache) have the max cost property. Is this property used to limit the number of megabytes of images saved? When the limit is exceeded, do they have a mechanism to delete photos?

I have read the Kingfisher source code, but I am still unclear about the default behavior and the mechanism of the ImageCache in terms of memory and disk usage. I would appreciate it if someone could explain how ImageCache manages its caching strategy and how the max cost property functions in both MemoryCache and DiskCache.

[ad_2]

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top