繁体   English   中英

在v5中将预取映像复制到内存(SDWebImageCacheMemoryOnly)

[英]Replicate Prefetching images into memory (SDWebImageCacheMemoryOnly) in v5

使用SDWebImage v4时,可以设置选项以仅通过以下方式将图像缓存在内存中

SDWebImagePrefetcher.sharedImagePrefetcher.options = SDWebImageCacheMemoryOnly;

这似乎不再是v5的选项,因此是这个问题。 默认情况下,似乎缓存的图像来自光盘。 (某些图像会延迟显示在屏幕上,我之前通过在内存中预取来解决了这些问题)。

我在迁移指南中看到,v5现在可以拆分磁盘和内存缓存,但是我无法弄清楚如何告诉预取器仅将图像存储在内存中。

来自库维护者之一的答案,原始内容可以在https://github.com/SDWebImage/SDWebImage/issues/2698找到。

有一个名为storeCacheType的上下文选项,值类型为SDImageCacheType。 请参阅有关文档。

/**
 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;

所以。 您只需要控制您的预取程序,即可将SDImageCacheTypeMemory枚举用于此存储高速缓存类型控件。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM