add examples for services
This commit is contained in:
parent
598e1c931c
commit
b7279b55c2
@ -36,6 +36,9 @@ fun CoroutineScope.launchPriceUpdate(
|
||||
): Job = launch {
|
||||
val cache = ArrayDeque<Pair<Instant, BigDecimal>>()
|
||||
|
||||
//restore from db
|
||||
val now = Clock.System.now()
|
||||
cache.addAll(db.restorePrice((now-duration)..now))
|
||||
|
||||
//read job
|
||||
launch {
|
||||
@ -61,7 +64,7 @@ fun CoroutineScope.launchPriceUpdate(
|
||||
//cache cleanup job
|
||||
launch {
|
||||
while (isActive) {
|
||||
delay(1.minutes)
|
||||
delay(10.minutes)
|
||||
val now = Clock.System.now()
|
||||
cache.removeIf { now - it.first > duration }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user