AUTOMATIC will store only the unmodified data backing your load when you’re loading remote data (like from URLs) because downloading remote data is expensive compared to resizing data already on disk. The default strategy, AUTOMATIC, tries to use the optimal strategy for local and remote images. The available strategies allow you to prevent your load from using or writing to the disk cache or choose to cache only the unmodified original data backing your load, only the transformed thumbnail produced by your load, or both. Disk Cache StrategiesĭiskCacheStrategy can be applied with the diskCacheStrategy method to an individual request. Glide provides a number of options that allow you to choose how loads will interact with Glide’s caches on a per request basis. To generate the name of disk cache keys on disk, the individual elements of the keys are hashed to create a single String key, which is then used as the file name in the disk cache. The keys used for active resources and the memory cache also differ slightly from those used from the resource disk cache to accomodate in memory Options like those thataffect the configuration of the Bitmap or other decode time only parameters. The requested data type (Bitmap, GIF, etc).In fact, the cache keys for steps 1-3 (Active resources, memory cache, resource disk cache) also include a number of other pieces of data including: If you are using a custom model, it needs to correctly implements hashCode() and equals() The model the load is requested for (File, Uri, Url).In Glide 4, all cache keys contain at least two elements: If all four steps fail to find the image, then Glide will go back to the original source to retrieve the data (the original File, Uri, Url etc).įor details on default sizes and locations of Glide’s caches or to configure those parameters, see the configuration page. The second two steps check to see if the image is on disk and return quickly, but asynchronously. The first two steps check to see if the resource is in memory and if so, return the image immediately. Data - Was the data this image was obtained from written to the disk cache before?.Resource - Has this image been decoded, transformed, and written to the disk cache before?.Memory cache - Was this image recently loaded and still in memory?.Active resources - Is this image displayed in another View right now?.By default, Glide checks multiple layers of caches before starting a new request for an image:
0 Comments
Leave a Reply. |