4

i'm using the amazing SDWebImage project, to refresh the download of an image i use this:

[[SDImageCache sharedImageCache] removeImageForKey:img_key fromDisk:YES];

and works, but i want to know if it's possible to give a tag for some images, so i can clear the cache for a set of images and not for only one, it's that possible?

chancyWu
  • 14,073
  • 11
  • 62
  • 81
Piero
  • 9,173
  • 18
  • 90
  • 160

2 Answers2

3

SDImageCache has a init method named - (id)initWithNamespace:(NSString *)ns;

you can use it to init a new instance instead of sharedImageCache, thus you can clearDisk, clearMemory without affecting others.

limboy
  • 3,879
  • 7
  • 37
  • 53
0

as you can see SDImageCache is using memCache ( NSCache ). You cannot remove defined set of images by tags for removing. You can clean memory/clear disk using this methods from.

- (void)clearMemory;
- (void)clearDisk;

I suggest you to create own nscache to define keys for images that you would like to remove. Then you can easily change it, or extend SDImageCache.

Cheers

Unheilig
  • 16,196
  • 193
  • 68
  • 98