Is the Disk Cache safe across multiple processes? #964
-
OkHttp Cache is single instance/process, although you can reuse the same instance with multiple clients. What are the restrictions/guarantees for the new Coil disk cache in 2? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
I believe it's the same in Coil 2.x (it's single instance/process). By default, we share a |
Beta Was this translation helpful? Give feedback.
-
Not from me, it predates my time. I think reuse of this in any form is a good thing. Let us know if there are non trivial bug fixes or any efforts required for KMM. cc @swankjesse |
Beta Was this translation helpful? Give feedback.
-
Yep, glad this could be helpful and I think it's useful to expose the File this way. The only extra thing I'd consider for Coil is using SQLite instead of the journal file. It'd be a difficult migration, but once it's done you could keep more metadata (image dimensions? Full-size URL?). I'd switch OkHttp to SQLite but that is not available outside of Android. |
Beta Was this translation helpful? Give feedback.
-
Good point. On Android we could probably just use SQLite instead of a journal and keep that as an implementation detail. |
Beta Was this translation helpful? Give feedback.
I believe it's the same in Coil 2.x (it's single instance/process). By default, we share a
DiskCache
instance betweenImageLoader
s to prevent multiple disk cache instances acting in the same directory. Internally, Coil'sDiskLruCache
is a slightly modified version of OkHttp's (also let me know if you want better credits added to that file - I only kept the existing file header).