SDImageCacheConfig

@interface SDImageCacheConfig : NSObject <NSCopying>

The class contains all the config for image cache

Note

This class conform to NSCopying, make sure to add the property in copyWithZone: as well.
  • Gets the default cache config used for shared instance or initialization when it does not provide any cache config. Such as SDImageCache.sharedImageCache.

    Note

    You can modify the property on default cache config, which can be used for later created cache instance. The already created cache instance does not get affected.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nonnull, class) SDImageCacheConfig *defaultCacheConfig;

    Swift

    class var `default`: SDImageCacheConfig { get }
  • Whether or not to disable iCloud backup Defaults to YES.

    Declaration

    Objective-C

    @property (nonatomic) BOOL shouldDisableiCloud;

    Swift

    var shouldDisableiCloud: Bool { get set }
  • Whether or not to use memory cache

    Note

    When the memory cache is disabled, the weak memory cache will also be disabled. Defaults to YES.

    Declaration

    Objective-C

    @property (nonatomic) BOOL shouldCacheImagesInMemory;

    Swift

    var shouldCacheImagesInMemory: Bool { get set }
  • Declaration

    Objective-C

    @property (nonatomic) BOOL shouldUseWeakMemoryCache

    Swift

    var shouldUseWeakMemoryCache: Bool { get set }
  • Whether or not to remove the expired disk data when application entering the background. (Not works for macOS) Defaults to YES.

    Declaration

    Objective-C

    @property (nonatomic) BOOL shouldRemoveExpiredDataWhenEnterBackground;

    Swift

    var shouldRemoveExpiredDataWhenEnterBackground: Bool { get set }
  • The reading options while reading cache from disk. Defaults to 0. You can set this to NSDataReadingMappedIfSafe to improve performance.

    Declaration

    Objective-C

    @property (nonatomic) NSDataReadingOptions diskCacheReadingOptions;

    Swift

    var diskCacheReadingOptions: NSData.ReadingOptions { get set }
  • The writing options while writing cache to disk. Defaults to NSDataWritingAtomic. You can set this to NSDataWritingWithoutOverwriting to prevent overwriting an existing file.

    Declaration

    Objective-C

    @property (nonatomic) NSDataWritingOptions diskCacheWritingOptions;

    Swift

    var diskCacheWritingOptions: NSData.WritingOptions { get set }
  • The maximum length of time to keep an image in the disk cache, in seconds. Setting this to a negative value means no expiring. Setting this to zero means that all cached files would be removed when do expiration check. Defaults to 1 week.

    Declaration

    Objective-C

    @property (nonatomic) NSTimeInterval maxDiskAge;

    Swift

    var maxDiskAge: TimeInterval { get set }
  • The maximum size of the disk cache, in bytes. Defaults to 0. Which means there is no cache size limit.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger maxDiskSize;

    Swift

    var maxDiskSize: UInt { get set }
  • The maximum “total cost” of the in-memory image cache. The cost function is the bytes size held in memory.

    Note

    The memory cost is bytes size in memory, but not simple pixels count. For common ARGB8888 image, one pixel is 4 bytes (32 bits). Defaults to 0. Which means there is no memory cost limit.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger maxMemoryCost;

    Swift

    var maxMemoryCost: UInt { get set }
  • The maximum number of objects in-memory image cache should hold. Defaults to 0. Which means there is no memory count limit.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger maxMemoryCount;

    Swift

    var maxMemoryCount: UInt { get set }
  • Declaration

    Objective-C

    @property (nonatomic) SDImageCacheConfigExpireType diskCacheExpireType

    Swift

    var diskCacheExpireType: SDImageCacheConfigExpireType { get set }
  • The custom file manager for disk cache. Pass nil to let disk cache choose the proper file manager. Defaults to nil.

    Note

    This value does not support dynamic changes. Which means further modification on this value after cache initialized has no effect.

    Note

    Since NSFileManager does not support NSCopying. We just pass this by reference during copying. So it’s not recommend to set this value on defaultCacheConfig.

    Declaration

    Objective-C

    @property (strong, nonatomic, nullable) NSFileManager *fileManager;

    Swift

    var fileManager: FileManager? { get set }
  • The custom memory cache class. Provided class instance must conform to SDMemoryCache protocol to allow usage. Defaults to built-in SDMemoryCache class.

    Note

    This value does not support dynamic changes. Which means further modification on this value after cache initialized has no effect.

    Declaration

    Objective-C

    @property (nonatomic, nonnull) Class memoryCacheClass;

    Swift

    var memoryCacheClass: AnyClass { get set }
  • The custom disk cache class. Provided class instance must conform to SDDiskCache protocol to allow usage. Defaults to built-in SDDiskCache class.

    Note

    This value does not support dynamic changes. Which means further modification on this value after cache initialized has no effect.

    Declaration

    Objective-C

    @property (nonatomic, nonnull) Class diskCacheClass;

    Swift

    var diskCacheClass: AnyClass { get set }