PINRemoteImageCaching.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // PINRemoteImageCaching.h
  3. // Pods
  4. //
  5. // Created by Aleksei Shevchenko on 7/25/16.
  6. //
  7. //
  8. #import <Foundation/Foundation.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. @protocol PINRemoteImageCaching;
  11. typedef void (^PINRemoteImageCachingObjectBlock)(id<PINRemoteImageCaching> cache, NSString *key, id __nullable object);
  12. /**
  13. * Image Cache is responsible for actual image caching.
  14. */
  15. @protocol PINRemoteImageCaching <NSObject>
  16. //******************************************************************************************************
  17. // Memory cache methods
  18. //******************************************************************************************************
  19. - (nullable id)objectFromMemoryForKey:(NSString *)key;
  20. - (void)setObjectInMemory:(id)object forKey:(NSString *)key withCost:(NSUInteger)cost;
  21. //******************************************************************************************************
  22. // Disk cache methods
  23. //******************************************************************************************************
  24. - (nullable id)objectFromDiskForKey:(NSString *)key;
  25. - (void)objectFromDiskForKey:(NSString *)key completion:(nullable PINRemoteImageCachingObjectBlock)completion;
  26. - (void)setObjectOnDisk:(id)object forKey:(NSString *)key;
  27. - (BOOL)objectExistsForKey:(NSString *)key;
  28. - (void)removeObjectForKey:(NSString *)key;
  29. - (void)removeObjectForKey:(NSString *)key completion:(nullable PINRemoteImageCachingObjectBlock)completion;
  30. - (void)removeAllObjects;
  31. @optional
  32. - (void)removeObjectForKeyFromMemory:(NSString *)key;
  33. @end
  34. NS_ASSUME_NONNULL_END