How to add cache key for InputStream?

19 views
Skip to first unread message

Tomasz Raganowicz

unread,
Sep 9, 2022, 6:14:16 AM9/9/22
to Glide
I am loading thumbnails like this:

val cacheKey : String
...
val thumbnail = Glide.with(context).load(thumbInputStream)
Glide.with(context).load("").thumbnail(thumbnail).into(holder.imageView)

I would like to use cache key to cache my input streams.

What are the options for me to use cacheKey?

So far I've got myself into these conclusions.
1. signature() method is for cache invalidation, not for specifying custom cache key, so it won't be any use here.

2.  I can't override: GlideUrl.getCacheKey() method, as the GlideUrl operates on string/URL instead of InputStream.

3. I've found this approach: 
https://github.com/bumptech/glide/issues/501#issuecomment-122580199
but, it is pretty dated (2015), the interface has changed slightly.
Is it still applicable and the only way to achieve caching for InputStreams?

Any help in this topic much appreciated,
Thanks !

Róbert Papp (TWiStErRob)

unread,
Sep 10, 2022, 4:46:07 AM9/10/22
to Glide
1 is your solution, you can only invalidate a cache if you have a key that's changing. If it doesn't change, it's just a cache key.
Reply all
Reply to author
Forward
0 new messages