Kache
Kache copied to clipboard
how to use this?? property must be initialize or abstract
code:
package com.my.project
import com.mayakapps.kache.FileKache
import com.mayakapps.kache.KacheStrategy
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class AnilistQuery {
val cache : FileKache // error here...
init {
GlobalScope.launch (Dispatchers.Main)
{
val cache = FileKache(directory = "cache", maxSize = 10 * 1024 * 1024) {
// Other optional configurations
strategy = KacheStrategy.MRU
// ...
}
}
}
error: i am getting error: Property must be initialized or be abstract
how to use this??
I guess you should initialize cache in a blocking way here (and Dispatchers.Main is the default anyway), so just use
class AnilistQuery {
val cache = runBlocking {
FileKache(directory = "cache", maxSize = 10 * 1024 * 1024) {
// Other optional configurations
strategy = KacheStrategy.MRU
// ...
}
}
}