rs/SDWebImage — pull request #282 by TomThorpe (2013-01-27 01:24:06+00:00)
Title: Adding a new property on SDImageCache called cachingPolicy.

Adding a new property on SDImageCache called cachingPolicy. I think this is particularly useful for people who don't want to cache to disk, so would rather just cache to memory.

The type of this is SDImageCacheType (reusing the existing enum). It lets you specify the default caching behaviour of one of three values; none (disables loading images from cache completely, forcing reload each time), memory only or disk.

This is so you can be more specific about the caching behaviour. You can leave the behaviour as is and cache to disk, or you can choose not to cache to disk and only cache to memory, or you can choose not to use the cache at all.

The default value of cachingPolicy if you don't change it is "disk" (SDImageCacheTypeDisk) - as was the default before this change.

You can change the value by accessing the shared instance of SDImageCache and modifying the property, e.g:
[SDImageCache sharedImageCache].cachingPolicy = SDImageCacheTypeMemory;

This cachingPolicy default applies to storeImage:forKey and storeImage:imageData:forKey where the toDisk property doesn't exist. If you call one of the storeImage methods that has the toDisk property, that will take precedence over the cachingPolicy property.

Also changed the call in SDWebImageManager to call the method that uses this property, instead of always being to disk like it was before.