Kaches
Generic caches written in Kotlin.
Create cache with LRU
eviction having maximum 1000
items:
val cache = cache<Int, String> {
eviction = Eviction.LRU
size = 1000
getValue = { key -> key.toString() }
}
Create cache with RANDOM
eviction having maximum 1000
items:
val cache = cache<Int, String> {
eviction = Eviction.RANDOM
size = 1000
getValue = { key -> key.toString() }
}
Create cache with LIFE_TIME
eviction with cached values living one second:
val cache = cache<Int, String> {
eviction = Eviction.LIFE_TIME
lifeTime = 1000
getValue = { key -> key.toString() }
currentTimeMillis = { System.currentTimeMillis() }
}
Create cache with IDLE_TIME
eviction with cached values evicted after being unused for one second:
val cache = cache<Int, String> {
eviction = Eviction.IDLE_TIME
idleTime = 1000
getValue = { key -> key.toString() }
currentTimeMillis = { System.currentTimeMillis() }
}