簡體   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