candlefinance/faster-image

Clear cache

Closed this issue · 1 comments

Is there a way to clear cache, or plans to implement this feature? This would be useful for testing/debug.

I think in Nuke for iOS it'll look something like this

Nuke.Cache.shared.removeAll()
Nuke.DataLoader.sharedUrlCache.removeAllCachedResponses()

and Coil for Android looking like this

fun clearCache(context: Context, memory: Boolean = true, file: Boolean= true) {
    // 1) clear memory cache
    if (memory) {
        val imageLoader = context.imageLoader
        imageLoader.memoryCache.clear()
    }
    // 2) clear file cache
    if (file) {
        val cache = CoilUtils.createDefaultCache(context)
        cache.directory().deleteRecursively()
    }
}

I can maybe take a look and open a PR sometime this week, unless someone beats me to it 😁

I've opened a PR here for iOS. I'm not as familiar with Kotlin/Android native modules just yet so I'll take a look at that next