Adding a new property on SDImageCache called cachingPolicy. #282
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.