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

[Question] Replicate Prefetching images into memory (SDWebImageCacheMemoryOnly) in v5? #2698

Closed
3 tasks done
xzilja opened this issue Apr 18, 2019 · 2 comments
Closed
3 tasks done
Labels

Comments

@xzilja
Copy link

xzilja commented Apr 18, 2019

New Issue Checklist

Issue Info

Info Value
Platform Name ios
Platform Version 12.0
SDWebImage Version 5.0.0
Integration Method cocoapods
Xcode Version Xcode 10
Repro rate 100%
Repro with our demo prj Likely yes
Demo project link -

Issue Description and Steps

While using SDWebImage v4 it was possible to set options to cache images in memory only via

SDWebImagePrefetcher.sharedImagePrefetcher.options = SDWebImageCacheMemoryOnly;

This no longer seems to be an option with v5, hence this question. By default it seems that cached images are coming from disc. (Some images appear on screen with delay, which I previously solved by prefetching them in memory).

I saw in migration guide that v5 now splits disc and memory cache, but I am not able to figure out how to tell prefetcher to store images in memory only.

@xzilja xzilja changed the title [Question] Replicate SDWebImageCacheMemoryOnly in v5? [Question] Replicate Prefetching images into memory (SDWebImageCacheMemoryOnly) in v5? Apr 18, 2019
@xzilja
Copy link
Author

xzilja commented Apr 18, 2019

@xzilja xzilja closed this as completed Apr 18, 2019
@dreampiggy
Copy link
Contributor

dreampiggy commented Apr 19, 2019

There is a context option called storeCacheType, the value type is SDImageCacheType. See the documentation about it.

/**
 A SDImageCacheType raw value which specify the cache type when the image has just been downloaded and will be stored to the cache. Specify `SDImageCacheTypeNone` to disable cache storage; `SDImageCacheTypeDisk` to store in disk cache only; `SDImageCacheTypeMemory` to store in memory only. And `SDImageCacheTypeAll` to store in both memory cache and disk cache.
 If not provide or the value is invalid, we will use `SDImageCacheTypeAll`. (NSNumber)
 */
FOUNDATION_EXPORT SDWebImageContextOption _Nonnull const SDWebImageContextStoreCacheType;

So. You just need to control your prefetcher, to use the SDImageCacheTypeMemory enum for this store cache type control.

SDWebImagePrefetcher.sharedImagePrefetcher.context = @{SDWebImageContextStoreCacheType : @(SDImageCacheTypeMemory)};

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

No branches or pull requests

2 participants