Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a new property on SDImageCache called cachingPolicy. #282

Closed
wants to merge 1 commit into from
Closed

Adding a new property on SDImageCache called cachingPolicy. #282

wants to merge 1 commit into from

Conversation

TomThorpe
Copy link

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.

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.
@rs
Copy link
Member

rs commented Feb 17, 2013

See SDWebImageCacheMemoryOnly

@rs rs closed this Feb 17, 2013
@TomThorpe
Copy link
Author

No worries - At the time of writing this SDWebImageCacheMemoryOnly didn't work correctly (since been fixed in #287 ), so while I was investigating that, I had thought it might've been useful to be able to choose to not even cache to memory. SDWebImageCacheMemoryOnly is fine though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants