enormego / EGOCache

Fast Caching for Objective-C (iPhone & Mac Compatible)
MIT License
1.33k stars 290 forks source link

Removing a cached object by key is not always possible #5

Closed jpm closed 13 years ago

jpm commented 13 years ago

There seems to be a missing feature here somewhere related to EGOCache and EGOImageView. The use case is to force the removal of a cached image object from the system. The image itself was initially retrieved and cached with EGOImageView, but perhaps the image has been changed and the cached one is not valid anymore.

There's a handy [-EGOCache removeCacheForKey:] method which takes in a key string (image URL), but that URL doesn't match up with the internal representation of the key, since EGOImageLoader uses a static method keyForURL() to generate a better key name.

I was able to hack around this by copying the keyForURL method into my own file to get the internal version of the cache key, but that's ugly and nasty. The real fix is to provide a method to remove an image from the cache somehow.

Let me know if I'm missing something obvious here.

--Joao

jpm commented 13 years ago

The other obvious work around would be to call [[EGOCache currentCache] clearCache] but I don't want to remove everything, just this one object.

shnhrrsn commented 13 years ago

This issue should be resolved now in EGOImageLoader as of c8fbdaa61d6ef7114219, there's a new method called: clearCacheForURL. Hope this helps!

envil commented 11 years ago

It's seem that [[EGOCache currentCache] clearCache] doesn't work at all. The cache is still there. The images are loaded using the cache, not downloading again after this method is called. Please consider this.