TransWikia.com

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

Stack Overflow Asked by coolcool1994 on January 28, 2021

  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

One Answer

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

Answered by alokHarman on January 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP