Open AlexTrotsenko opened 9 years ago
Looks like I have found the way to avoid keeping unnecessary image in cache. It will still caches it with normal call, but after that I can remove it from memory with call like:
MemoryCacheUtils.removeFromCache(backgroundImgUri, ImageLoader.getInstance().getMemoryCache());
How to remove From Cache for all images?
@iman2420 Here is some method in class ImageLoader
. I think it is what you wanted.
/**
* Returns memory cache
*
* @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
*/
public MemoryCache getMemoryCache() {
checkConfiguration();
return configuration.memoryCache;
}
/**
* Clears memory cache
*
* @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
*/
public void clearMemoryCache() {
checkConfiguration();
configuration.memoryCache.clear();
}
/**
* Returns disk cache
*
* @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
*/
public DiskCache getDiskCache() {
checkConfiguration();
return configuration.diskCache;
}
/**
* Clears disk cache.
*
* @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
*/
public void clearDiskCache() {
checkConfiguration();
configuration.diskCache.clear();
}
If app shows image once per start (e.g. background loading image on start-up), it could be nice to have ability to skip caching this image in memory cache.
Specially it could be handy for time-based cache. LRU cache could also contribute from this as well.