Tuesday, June 10, 2014

[iOS] Image Cache Libraries Comparison

The implementation is to pack together images of the same dimensions to a single file(image table), all images in image table are decompressed, and original image never be cached. 
When an image request is coming, it’s going to check the image table and simply return it immediately if it can be found, or else to download asynchronously from remote server, by the way, the decompressed image is added to the image table after it is done.
Advantage:
  1. All images of the same dimension are stored in a single file(image table).
  2. Every image is stored with decompressing, original image never be stored.
  3. Image format can be specified before storing, so no need to format every time when using.
  4. All above prove it’s very fast to read the image and display them. 
Weakness:
  1. All images are decompressed, it takes more space to store.
  2. The image table size is limited, the big images take more size and overall reduce the number of cached image.
  3. One image with multiple formats stores in multiple copies.
  4. Need initial configuration
The implementation is common, the original image is automatically cached when downloading from remote, and decompress and resize it when it’s about to using it. 
When image request is coming, it’s going to check the cache and simply return it immediately if it can be found, or else to download asynchronously from remote server.

It’s similar to SDWebImage.

It provides two types of cache mechanism, memory cache and disk cache, it applies to cache any object. If using it, you have to check if need to download image from remote by yourself.

No comments:

Post a Comment