SDImageCacheConfig.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * This file is part of the SDWebImage package.
  3. * (c) Olivier Poitrey <rs@dailymotion.com>
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. */
  8. #import <Foundation/Foundation.h>
  9. #import "SDWebImageCompat.h"
  10. typedef NS_ENUM(NSUInteger, SDImageCacheConfigExpireType) {
  11. /**
  12. * When the image is accessed it will update this value
  13. */
  14. SDImageCacheConfigExpireTypeAccessDate,
  15. /**
  16. * The image was obtained from the disk cache (Default)
  17. */
  18. SDImageCacheConfigExpireTypeModificationDate
  19. };
  20. @interface SDImageCacheConfig : NSObject
  21. /**
  22. * Decompressing images that are downloaded and cached can improve performance but can consume lot of memory.
  23. * Defaults to YES. Set this to NO if you are experiencing a crash due to excessive memory consumption.
  24. */
  25. @property (assign, nonatomic) BOOL shouldDecompressImages;
  26. /**
  27. * Whether or not to disable iCloud backup
  28. * Defaults to YES.
  29. */
  30. @property (assign, nonatomic) BOOL shouldDisableiCloud;
  31. /**
  32. * Whether or not to use memory cache
  33. * @note When the memory cache is disabled, the weak memory cache will also be disabled.
  34. * Defaults to YES.
  35. */
  36. @property (assign, nonatomic) BOOL shouldCacheImagesInMemory;
  37. /**
  38. * The option to control weak memory cache for images. When enable, `SDImageCache`'s memory cache will use a weak maptable to store the image at the same time when it stored to memory, and get removed at the same time.
  39. * However when memory warning is triggered, since the weak maptable does not hold a strong reference to image instacnce, even when the memory cache itself is purged, some images which are held strongly by UIImageViews or other live instances can be recovered again, to avoid later re-query from disk cache or network. This may be helpful for the case, for example, when app enter background and memory is purged, cause cell flashing after re-enter foreground.
  40. * Defautls to YES. You can change this option dynamically.
  41. */
  42. @property (assign, nonatomic) BOOL shouldUseWeakMemoryCache;
  43. /**
  44. * The reading options while reading cache from disk.
  45. * Defaults to 0. You can set this to `NSDataReadingMappedIfSafe` to improve performance.
  46. */
  47. @property (assign, nonatomic) NSDataReadingOptions diskCacheReadingOptions;
  48. /**
  49. * The writing options while writing cache to disk.
  50. * Defaults to `NSDataWritingAtomic`. You can set this to `NSDataWritingWithoutOverwriting` to prevent overwriting an existing file.
  51. */
  52. @property (assign, nonatomic) NSDataWritingOptions diskCacheWritingOptions;
  53. /**
  54. * The maximum length of time to keep an image in the cache, in seconds.
  55. */
  56. @property (assign, nonatomic) NSInteger maxCacheAge;
  57. /**
  58. * The maximum size of the cache, in bytes.
  59. */
  60. @property (assign, nonatomic) NSUInteger maxCacheSize;
  61. /**
  62. * The attribute which the clear cache will be checked against when clearing the disk cache
  63. * Default is Modified Date
  64. */
  65. @property (assign, nonatomic) SDImageCacheConfigExpireType diskCacheExpireType;
  66. @end