mirror of https://git.sr.ht/~oppen/ariane
22 lines
600 B
Kotlin
22 lines
600 B
Kotlin
package oppen.tva.io
|
|
|
|
import androidx.collection.LruCache
|
|
import java.net.URI
|
|
|
|
object RuntimeCache {
|
|
|
|
private const val CACHE_SIZE = 4 * 1024 * 1024
|
|
private val lruCache = LruCache<String, Pair<GeminiResponse.Header, List<String>>>(CACHE_SIZE)
|
|
|
|
fun put(uri: URI, header: GeminiResponse.Header, lines: List<String>){
|
|
lruCache.put(uri.toString(), Pair(header, lines))
|
|
}
|
|
|
|
fun get(uri: URI): Pair<GeminiResponse.Header, List<String>>? = lruCache[uri.toString()]
|
|
|
|
fun clear() = lruCache.evictAll()
|
|
|
|
fun remove(address: String) {
|
|
lruCache.remove(address)
|
|
}
|
|
} |