Monday, June 9, 2014

[iOS] Fast Image Cache

  • Stores images of similar sizes and styles together
  • Persists image data to disk
  • Returns images to the user significantly faster than traditional methods
  • Automatically manages cache expiry based on recency of usage
  • Utilizes a model-based approach for storing and retrieving images
  • Allows images to be processed on a per-model basis before being stored into the cache
Specials:
  1. It packs together images of the same dimensions to a single file.
  2. Uncompress image data to the file, so Fast Image Cache works best with smaller images.
  3. Image table size is limited, how many images can it stores that depends on the images size, it will replace the old ones when it's to add more when it's full.
  4. Image table files are stored in the user's caches directory in a subdirectory called ImageTables
  5. Does not persist the original source images
Notes:
  1. Note that it is an entity and an image format name that uniquely identifies the desired image in the image cache. As a format name uniquely identifies an image table, the entity alone uniquely identifies the desired image data in an image table.
  2. The image cache never returns a UIImage directly. The requested image is included in the completion block. The return value will indicate whether or not the image already exists in the image cache.
  3. -retrieveImageForEntity:withFormatName:completionBlock: is a synchronous method. If the requested image already exists in the image cache, the completion block will be called immediately. There is an asynchronous counterpart to this method called -asynchronouslyRetrieveImageForEntity:withFormatName:completionBlock:.
  4. If a requested image does not already exist in the image cache, then the image cache invokes the necessary actions to request the source image for its delegate. Afterwards, perhaps some time later, the completion block will be called.
  5. If an image request is already in progress, it can be cancelled.


No comments:

Post a Comment