-
-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
same key is expiring twice with this config
val cache = Cache.Builder<String, String>()
.maximumCacheSize(1_00)
.expireAfterWrite(2.seconds)
.expireAfterAccess(5.seconds)
.eventListener { event ->
when (event) {
is CacheEvent.Created -> {}
is CacheEvent.Updated -> {}
is CacheEvent.Evicted -> {
scope.launch {
println("Evicted ${event.key}")
}
}
is CacheEvent.Expired -> {
scope.launch {
println("Expire ${event.key}")
}
}
is CacheEvent.Removed -> {
println("Evicted")
}
}
}
.build()
here I launch different coroutine adding value in the cache
for (n in 0..100) {
delay(100)
scopeL.launch {
schemas.put("n$n", "some value")
println("n$n")
}
}
Result
...
adding n18
adding n19
adding n20
Expire n0
Expire n2
Expire n1
Expire n0
Expire n1
Expire n2
adding n21
Expire n3
Expire n3
adding n22
Expire n4
Expire n4
adding n23
Expire n5
Expire n5
adding n24
Expire n6
Expire n6
adding n25
...
The same keys are expiring twice
Metadata
Metadata
Assignees
Labels
No labels