Skip to content

Commit

Permalink
ModelCache totalInvalidation fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
bjsvedin committed Mar 7, 2024
1 parent e64793e commit 27d21eb
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -121,8 +121,13 @@ class ModelCache<T : HasId<ID>, ID : Comparable<ID>>(
inner class ListImpl(val query: Query<T>) : Readable<List<T>> {
var live: Int = 0
var lastSet: Double = 0.0
val now = clockMillis()
val upToDate: Boolean get() = ready && (live > 0 || (now - lastSet < cacheMs && now > totalInvalidation))
var lastInvalidateCheck = clockMillis()
val upToDate: Boolean get() {
val now = clockMillis()
val result = (ready && (live > 0 || (now - lastSet < cacheMs && lastInvalidateCheck > totalInvalidation)))
lastInvalidateCheck = now
return result
}
val comparator = query.orderBy.comparator ?: compareBy { it._id }

var complete: Boolean = false
Expand Down

0 comments on commit 27d21eb

Please sign in to comment.