Android-Universal-Image-Loader icon indicating copy to clipboard operation
Android-Universal-Image-Loader copied to clipboard

Skipping caching of distinct image

Open AlexTrotsenko opened this issue 10 years ago • 3 comments

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.

AlexTrotsenko avatar Jan 21 '15 14:01 AlexTrotsenko

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());

AlexTrotsenko avatar Feb 20 '15 15:02 AlexTrotsenko

How to remove From Cache for all images?

iman2420 avatar Sep 30 '17 13:09 iman2420

@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();
	}

ouyangzn avatar Oct 09 '17 02:10 ouyangzn