fix ProjectionSnapshotRepositoryInMemory.excludeTheHeadBySize
This commit is contained in:
@@ -144,14 +144,8 @@ class ProjectionSnapshotRepositoryInMemory<E : Event<ID>, P : Projection<ID>, ID
|
|||||||
*/
|
*/
|
||||||
private fun FilteredList<P>.excludeTheHeadBySize(): FilteredList<P> {
|
private fun FilteredList<P>.excludeTheHeadBySize(): FilteredList<P> {
|
||||||
// filter if size exceeds the limit
|
// filter if size exceeds the limit
|
||||||
if (size > snapshotCacheConfig.maxSnapshotCacheSize) {
|
return sortedBy { it.first.lastEventVersion }
|
||||||
val numberToRemove = size - snapshotCacheConfig.maxSnapshotCacheSize
|
.dropLast(snapshotCacheConfig.maxSnapshotCacheSize)
|
||||||
if (numberToRemove > 0) {
|
|
||||||
return sortedBy { it.first.lastEventVersion }
|
|
||||||
.takeLast(numberToRemove)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,9 +11,8 @@ import io.kotest.assertions.nondeterministic.eventually
|
|||||||
import io.kotest.assertions.nondeterministic.eventuallyConfig
|
import io.kotest.assertions.nondeterministic.eventuallyConfig
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
import io.kotest.matchers.collections.shouldHaveSize
|
import io.kotest.matchers.collections.shouldHaveSize
|
||||||
import io.kotest.matchers.comparables.shouldBeGreaterThan
|
|
||||||
import io.kotest.matchers.equals.shouldBeEqual
|
import io.kotest.matchers.equals.shouldBeEqual
|
||||||
import io.kotest.matchers.ints.shouldBeLessThan
|
import io.kotest.matchers.shouldBe
|
||||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.joinAll
|
import kotlinx.coroutines.joinAll
|
||||||
@@ -148,8 +147,7 @@ class GameStateRepositoryTest :
|
|||||||
lastEventVersion shouldBeEqual 1000
|
lastEventVersion shouldBeEqual 1000
|
||||||
players shouldHaveSize 1000
|
players shouldHaveSize 1000
|
||||||
}
|
}
|
||||||
repo.count(aggregateId) shouldBeGreaterThan 20
|
repo.count(aggregateId) shouldBe 119
|
||||||
repo.count(aggregateId) shouldBeLessThan 30
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user