Skip to content

Commit

Permalink
pcms: fix possible issues with DataLoader<T>.cached lateinit var
Browse files Browse the repository at this point in the history
  • Loading branch information
Kostya Bats authored and kbats183 committed Nov 4, 2024
1 parent 376a8f3 commit a0e38bc
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public fun <T:Any> DataLoader<T>.cached(interval: Duration) = object : DataLoade
lateinit var cache: T
override suspend fun load(): T {
if (nextLoad?.hasPassedNow() != false) {
nextLoad = TimeSource.Monotonic.markNow() + interval
cache = this@cached.load()
nextLoad = TimeSource.Monotonic.markNow() + interval
} else {
logger(DataLoader::class.java).info {
"Not loading because of cache"
Expand Down

0 comments on commit a0e38bc

Please sign in to comment.