Questions about the cache files generated by the Picasso library on Android.

Asked 2 years ago, Updated 2 years ago, 28 views

Android is using Picasso.

I have set OkHttpDownloader for picasso and use it.

I have a question.

Looking at the internal logic, it seems that the picasso-cache folder is being cached under the cache folder.

If I ask you a question here,

1. I wonder what criteria the file name is based on.

ex)
bc58db106dfbdbf4dc8686589b160ec4.1
bc58db106dfbdbf4dc8686589b160ec4.0

android

2022-09-22 08:29

1 Answers

File name is Cache by OkHttp.It appears to be generated by a function called urlToKey() in java. I don't think it would be too much to understand that the source of the file name is image url.

  private static String urlToKey(Request request) {
    return Util.md5Hex(request.url().toString());
  }

You said you wanted to use the files stored in the disk cache. If you are using Picasso to load an image, you are already using this file internally. Picasso's internal cache logic processes the image to be read from memory or read from disk.

For example, loading the image http://a.jpg through Picasso will save it to memory and disk cache, and utilize memory and file cache the next time you load the image. Therefore, if you want to use the downloaded file, simply load the image with the same url.


2022-09-22 08:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.