I'm using Glide 4.0 and want to have the image loaded from the custom ModelLoader in the Memory and Disc caches. There are two cases.
In both cases, a found image seem to be cached on the Disc but not put into a Memory cache because I'm able to see placeholders before an image is loaded only on items with custom ModelLoaders. And I don't see any placeholders on items that are not using custom ModelLoaders and loading images from general URLs for example, the image is showing immediately.
What should be done to put image into Memory cache?
Your model needs to implements hashCode() / equals().
The key is now only used as a secondary key for discCache.
@Tolriq ok, will implement that. What about memory cache?
Memory cache is now based on your model hashCode/equals so if you do not implement it correctly Glide can't match your requests and can't use the memory cache :)
If 2 models are equals and same hashCode then Glide do the match and reuse it's memory cache.
The docs have been updated with more insisting on those. Maybe it's still not clear enough?
@Tolriq it works after implementing hashCode/equals in a model, thanks!
I was confused about LoadData constructor expecting Key object public LoadData(Key sourceKey, DataFetcher<Data> fetcher) that is not actually used for constructing a key for the cache.