How to clean up all the cache image
in code, How to clean up all the cache image?
That's a good point. Function to remove all cached images would be very useful.
Agreed. There should be a mechanism to remove the cached file. I think a static function for removing all cached images would work. Something like CacheableImage.clearCache();
For individual components I am thinking a property like 'clearCacheOnDestroy' as a boolean. Once set, on componentWillUnmount() it should check to see if the prop is set and if so remove it from the cache.
Thoughts ?
So, now only manually to delete the cache, and can not function to delete these pictures?
I was looking at the source code and it actually has a method that deletes the cached file (_deleteFilePath, here it is in use).
This method argument is filePath, which is calculated here at line 52, and uses cachePath and cacheKeys as variables.
Both variables are assigned in _processSource method.
So what would I do in order to delete a specific image from the cache:
- Create another method to calculate
cacheKey(sincecachePathis essentially source's URI host). Of course use this method in_processSource. - Create a static method, let's say:
clearCachedFilewhich would take a string (the URI), calculate host andcacheKey, then createsfilePathvariable and finally call_deleteFilePathwith this variable.
@jayesbe What do you think? If is there something I'm missing let me know.
If this is fine for you I'd happily create a PR with this.
@wachunei This makes sense to me. PR is definitely welcome.
@jayesbe will look into this next days!