I need to know how long a cached version of URI would be on the disk in fresco cache?
-
1whi don't you ask it's developers? – Vladyslav Matviienko Sep 25 '15 at 11:47
-
refer [documentation](http://frescolib.org/docs/caching.html#_) – Rahul Tiwari Sep 25 '15 at 11:52
-
I could't find any reference to it in the documentation :( – Whats Tools Sep 25 '15 at 11:54
-
*Unlike the others, this cache is not cleared when your app is backgrounded, or if it exits, or even if the device is turned off. The user can, of course, always clear it from Android's Settings menu.* – Blackbelt Sep 25 '15 at 11:55
-
1The point is, I need to know if it's cleared automatically. May be after 24 hours. or 10 days? – Whats Tools Sep 25 '15 at 11:57
-
Need to know if there is any Time-to-live option for files in cache – Whats Tools Sep 25 '15 at 11:58
1 Answers
As it is written at http://frescolib.org/docs/caching.html#trimming-the-caches:
When configuring the image pipeline, you can set the maximum size of each of the caches. But there are times when you might want to go lower than that. For instance, your application might have caches for other kinds of data that might need more space and crowd out Fresco's. Or you might be checking to see if the device as a whole is running out of storage space.
Fresco's caches implement the DiskTrimmable or MemoryTrimmable interfaces. These are hooks into which your app can tell them to do emergency evictions.
Your application can then configure the pipeline with objects implementing the DiskTrimmableRegistry and MemoryTrimmableRegistry interfaces.
These objects must keep a list of trimmables. They must use app-specific logic to determine when memory or disk space must be preserved. They then notify the trimmable objects to carry out their trims.
So, if you don't specify DiskTrimmable or MemoryTrimmable while configuration your ImagePipeline will be using default DiskTrimmable, MemoryTrimmable. So, after looking for default values in sources i found this:
private static DiskCacheConfig getDefaultMainDiskCacheConfig(final Context context) {
return DiskCacheConfig.newBuilder()
.setBaseDirectoryPathSupplier(
new Supplier<File>() {
@Override
public File get() {
return context.getApplicationContext().getCacheDir();
}
})
.setBaseDirectoryName("image_cache")
.setMaxCacheSize(40 * ByteConstants.MB)
.setMaxCacheSizeOnLowDiskSpace(10 * ByteConstants.MB)
.setMaxCacheSizeOnVeryLowDiskSpace(2 * ByteConstants.MB)
.build();
}
So conclusion is next: when the memory is full (40 ByteConstants.MB or 10 ByteConstants.MB or 2 ByteConstants.MB) - Fresco will delete old records and write new records(images). Maybe Fresco use this method.

- 490
- 1
- 7
- 12