ios – What do the cacheType values returned in SDWebImage sd_setImage mean?

0
87

[ad_1]

I’ve added cached images to UIImageviews using sd_setImage() in UITablelViewCells, as follows.

imageView.sd_setImage(with: url, placeholderImage: defaultImage) { image, error, cacheType, cacheURL in

}

My problem is occasionally when loading fresh cells the image is getting refetched from the server when it should be in cache and I can’t figure out why. While debugging I’ve been logging the cacheType, but it’s only printing as Int values, in range of 0, 1, 2.

I can’t find these values documented anywhere in SdWebImage docs. It’s defined as type SDImageCacheType in a objective C .h file as follows but I’m unclear how to translate numbers to types.

typedef NS_ENUM(NSInteger, SDImageCacheType) {
    /**
     * For query and contains op in response, means the image isn't available in the image cache
     * For op in request, this type is not available and take no effect.
     */
    SDImageCacheTypeNone,
    /**
     * For query and contains op in response, means the image was obtained from the disk cache.
     * For op in request, means process only disk cache.
     */
    SDImageCacheTypeDisk,
    /**
     * For query and contains op in response, means the image was obtained from the memory cache.
     * For op in request, means process only memory cache.
     */
    SDImageCacheTypeMemory,
    /**
     * For query and contains op in response, this type is not available and take no effect.
     * For op in request, means process both memory cache and disk cache.
     */
    SDImageCacheTypeAll
};

Is it just me, or does anyone else find SDWebImage documentation extremely confusing and hard to understand?

[ad_2]