coolcool1994
coolcool1994

Reputation: 3812

Manually save Bitmap or ByteArray into cache and manually delete one cache image using image url

  1. When I upload an image to server, I want to cache it in storage in Glide with Bitmap or ByteArray so once it is uploaded, I do not have to download it from server. I can achieve this using SDWebImage in iOS, but I can't find how to do this in Glide.

    [((SDImageCache *)webImageManager.imageCache) storeImage:image forKey:downloadURL completion:nil];

  2. Is there a way to manually delete just one cached image using one ImageURL? If image isn't needed again, I want to delete it from the user's device so it doesn't use user's device memory. Here too I can achieve this using SDWebImage in iOS, but I can't find how to do this in Glide.

    [((SDImageCache *)webImageManager.imageCache) removeImageForKey:imageUrl withCompletion:nil];

Thank you for your expertise

Upvotes: 1

Views: 239

Answers (1)

alokHarman
alokHarman

Reputation: 289

There is no interface in glide(or other image caching libs) to delete particular image from cache. You can clear entire cache. But you can skip caching in glide for particular image URI Use diskCacheStrategy(DiskCacheStrategy.NONE) to avoid disk caching and skipMemoryCache() to avoid caching in memory. for more information on glide caching http://bumptech.github.io/glide/doc/caching.html#cache-invalidation

Upvotes: 1

Related Questions