Fix the case that query full size key with thumbnail, cause the write back of thumnail to memory cache with wrong key
This commit is contained in:
parent
613a2bf988
commit
e7e9268a7e
|
@ -373,7 +373,11 @@ static NSString * _defaultDiskCacheDirectory;
|
||||||
SDImageCacheType cacheType = [context[SDWebImageContextStoreCacheType] integerValue];
|
SDImageCacheType cacheType = [context[SDWebImageContextStoreCacheType] integerValue];
|
||||||
shouldCacheToMomery = (cacheType == SDImageCacheTypeAll || cacheType == SDImageCacheTypeMemory);
|
shouldCacheToMomery = (cacheType == SDImageCacheTypeAll || cacheType == SDImageCacheTypeMemory);
|
||||||
}
|
}
|
||||||
if (diskImage && self.config.shouldCacheImagesInMemory && shouldCacheToMomery) {
|
if (context[SDWebImageContextImageThumbnailPixelSize]) {
|
||||||
|
// Query full size cache key which generate a thumbnail, should not write back to full size memory cache
|
||||||
|
shouldCacheToMomery = NO;
|
||||||
|
}
|
||||||
|
if (shouldCacheToMomery && diskImage && self.config.shouldCacheImagesInMemory) {
|
||||||
NSUInteger cost = diskImage.sd_memoryCost;
|
NSUInteger cost = diskImage.sd_memoryCost;
|
||||||
[self.memoryCache setObject:diskImage forKey:key cost:cost];
|
[self.memoryCache setObject:diskImage forKey:key cost:cost];
|
||||||
}
|
}
|
||||||
|
@ -581,6 +585,10 @@ static NSString * _defaultDiskCacheDirectory;
|
||||||
SDImageCacheType cacheType = [context[SDWebImageContextStoreCacheType] integerValue];
|
SDImageCacheType cacheType = [context[SDWebImageContextStoreCacheType] integerValue];
|
||||||
shouldCacheToMomery = (cacheType == SDImageCacheTypeAll || cacheType == SDImageCacheTypeMemory);
|
shouldCacheToMomery = (cacheType == SDImageCacheTypeAll || cacheType == SDImageCacheTypeMemory);
|
||||||
}
|
}
|
||||||
|
if (context[SDWebImageContextImageThumbnailPixelSize]) {
|
||||||
|
// Query full size cache key which generate a thumbnail, should not write back to full size memory cache
|
||||||
|
shouldCacheToMomery = NO;
|
||||||
|
}
|
||||||
// decode image data only if in-memory cache missed
|
// decode image data only if in-memory cache missed
|
||||||
diskImage = [self diskImageForKey:key data:diskData options:options context:context];
|
diskImage = [self diskImageForKey:key data:diskData options:options context:context];
|
||||||
if (shouldCacheToMomery && diskImage && self.config.shouldCacheImagesInMemory) {
|
if (shouldCacheToMomery && diskImage && self.config.shouldCacheImagesInMemory) {
|
||||||
|
|
Loading…
Reference in New Issue