XHWebImageAutoSizeCache.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // XHWebImageAutoSizeCache.h
  3. // XHWebImageHeightLayoutExample
  4. //
  5. // Created by zhuxiaohui on 2016/11/16.
  6. // Copyright © 2016年 it7090.com. All rights reserved.
  7. // https://github.com/CoderZhuXH/XHWebImageAutoSize
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. typedef void(^XHWebImageAutoSizeCacheCompletionBlock)(BOOL result);
  11. @interface XHWebImageAutoSizeCache : NSObject
  12. /**
  13. * Return global shared cache instance
  14. *
  15. * @return XHWebImageAutoSizeCache global instance
  16. */
  17. +(XHWebImageAutoSizeCache *)shardCache;
  18. /**
  19. * Store an imageSize into memory and disk cache at the given key.
  20. *
  21. * @param image The image to store
  22. * @param key The unique imageSize cache key, usually it's image absolute URL
  23. *
  24. * @return result
  25. */
  26. -(BOOL)storeImageSize:(UIImage *)image forKey:(NSString *)key;
  27. /**
  28. * Store an imageSize into memory and disk cache at the given key.
  29. *
  30. * @param image The image to store
  31. * @param key The unique imageSize cache key, usually it's image absolute URL
  32. * @param completedBlock An block that should be executed after the imageSize has been saved (optional)
  33. */
  34. -(void)storeImageSize:(UIImage *)image forKey:(NSString *)key completed:(XHWebImageAutoSizeCacheCompletionBlock)completedBlock;
  35. /**
  36. * Query the disk cache synchronously after checking the memory cache
  37. *
  38. * @param key The unique key used to store the wanted imageSize
  39. *
  40. * @return imageSize
  41. */
  42. -(CGSize)imageSizeFromCacheForKey:(NSString *)key;
  43. /**
  44. * Store an reloadState into memory and disk cache at the given key.
  45. *
  46. * @param state reloadState
  47. * @param key The unique reloadState cache key, usually it's image absolute URL
  48. *
  49. * @return result
  50. */
  51. -(BOOL)storeReloadState:(BOOL)state forKey:(NSString *)key;
  52. /**
  53. * Store an reloadState into memory and disk cache at the given key
  54. *
  55. * @param state reloadState
  56. * @param key The unique reloadState cache key, usually it's image absolute URL
  57. * @param completedBlock An block that should be executed after the reloadState has been saved (optional)
  58. */
  59. -(void)storeReloadState:(BOOL)state forKey:(NSString *)key completed:(XHWebImageAutoSizeCacheCompletionBlock)completedBlock;
  60. /**
  61. * Query the disk cache synchronously after checking the memory cache
  62. *
  63. * @param key The unique key used to store the wanted reloadState
  64. *
  65. * @return reloadState
  66. */
  67. -(BOOL)reloadStateFromCacheForKey:(NSString *)key;
  68. @end