How to invalidate Glide cache for some specific im

2019-05-08 21:27发布

I'm writing an app which needs to load a lot of images from the internet (a manga reader). I need to cache some thumbnail images for offline use, any others should be cleared when app closed.

I read some about cache invalidation on Glide page, they said the best way is to change the content url, but how Glide know if it is a modified url of old content or a new one? I'm new to Glide here.

https://github.com/bumptech/glide/wiki/Caching-and-Cache-Invalidation

Thank in advance :)

1条回答
啃猪蹄的小仙女
2楼-- · 2019-05-08 22:09

You can use following to load image:

Glide.with(context)
    .signature(new StringSignature(yourVersionMetadata))
    .into(imageView)

Just change yourVersionMetadata when you load image and it will not load from cache if yourVersionMetadata is different.

查看更多
登录 后发表回答