Is your feature request related to a problem? Please describe.
I couldn't find any straightforward way in the current ImageRequest.Builder APIs to easily invalidate both memory cache and disk cache through a key (be it either a String, or another object). It seems like I'm able to do this with memory cache via memoryCacheKeyExtras, but I don't see anything similar for disk cache. Could we consider adding it, or is there a limitation that makes this hard to do? I couldn't find any previous issue mentioning this as well.
I can create a custom interceptor to handle this and add my own .diskCacheKeyExtras() of sorts, but it seems like it would be useful to have this out of the box on the framework.
Describe the solution you'd like
Some way of setting diskCacheKeyExtras on the ImageRequest.Builder or something that accomplishes the same thing.
Additional context
Here's an use case I'm facing with to make this request clearer:
- Often there will be a need to append
&width=X&height=Y to the end of an image URL so we can load images more efficiently. We can currently easily do this by adding an interceptor that looks at the Interceptor.Chain image size and appends those parameters. This works great.
- But what if we need to invalidate an image from both the memory and disk caches based on another attribute (like a timestamp from the server, that does not go on the URL)? At first, you would think you could do:
.diskCacheKey("$url+$timestamp"), but then the issue is that this URL does not contain neither the width, nor the height from the interceptor, so something like rotating the device would not trigger an invalidate, when it should (since the width and height is now not part of the cache key). Essentially, we would want this timestamp to be added to the cache key after every interceptor ran, so like an "extra".
Is your feature request related to a problem? Please describe.
I couldn't find any straightforward way in the current
ImageRequest.BuilderAPIs to easily invalidate both memory cache and disk cache through a key (be it either a String, or another object). It seems like I'm able to do this with memory cache via memoryCacheKeyExtras, but I don't see anything similar for disk cache. Could we consider adding it, or is there a limitation that makes this hard to do? I couldn't find any previous issue mentioning this as well.I can create a custom interceptor to handle this and add my own
.diskCacheKeyExtras()of sorts, but it seems like it would be useful to have this out of the box on the framework.Describe the solution you'd like
Some way of setting
diskCacheKeyExtrason theImageRequest.Builderor something that accomplishes the same thing.Additional context
Here's an use case I'm facing with to make this request clearer:
&width=X&height=Yto the end of an image URL so we can load images more efficiently. We can currently easily do this by adding an interceptor that looks at theInterceptor.Chainimage size and appends those parameters. This works great..diskCacheKey("$url+$timestamp"), but then the issue is that this URL does not contain neither the width, nor the height from the interceptor, so something like rotating the device would not trigger an invalidate, when it should (since the width and height is now not part of the cache key). Essentially, we would want this timestamp to be added to the cache key after every interceptor ran, so like an "extra".