diff --git a/lapis2-docs/src/content/docs/maintainer-docs/concepts/caching.mdx b/lapis2-docs/src/content/docs/maintainer-docs/concepts/caching.mdx index 87f6362f..aa9b4ef5 100644 --- a/lapis2-docs/src/content/docs/maintainer-docs/concepts/caching.mdx +++ b/lapis2-docs/src/content/docs/maintainer-docs/concepts/caching.mdx @@ -5,12 +5,11 @@ description: LAPIS' caching concept import CacheSizeEndpointLink from '../../../../components/CacheSizeEndpointLink.astro'; -LAPIS uses Spring Boot's caching capabilities to cache insertion and mutation queries. +LAPIS uses Spring Boot's caching capabilities to cache aggregated, insertion and mutation queries. We decided to cache SILO actions that are relatively expensive to compute, but don't return much data (measured in size of the response body). -At the time of writing, we think that aggregated queries are fast enough to not require caching. -Details and FASTA actions are more expensive, but return potentially large amounts of data. +Details and FASTA actions are expensive, but return potentially large amounts of data. LAPIS offers an endpoint to check the current cache size (in number of cached entries) at `/actuator/metrics/cache.size`: diff --git a/lapis2/src/main/kotlin/org/genspectrum/lapis/silo/SiloQuery.kt b/lapis2/src/main/kotlin/org/genspectrum/lapis/silo/SiloQuery.kt index 4f2cceba..2854ddbf 100644 --- a/lapis2/src/main/kotlin/org/genspectrum/lapis/silo/SiloQuery.kt +++ b/lapis2/src/main/kotlin/org/genspectrum/lapis/silo/SiloQuery.kt @@ -151,7 +151,7 @@ sealed class SiloAction( override val limit: Int? = null, override val offset: Int? = null, val type: String = "Aggregated", - ) : SiloAction>(AggregationDataTypeReference(), cacheable = false) + ) : SiloAction>(AggregationDataTypeReference(), cacheable = true) @JsonInclude(JsonInclude.Include.NON_EMPTY) private data class MutationsAction( diff --git a/lapis2/src/test/kotlin/org/genspectrum/lapis/silo/SiloClientTest.kt b/lapis2/src/test/kotlin/org/genspectrum/lapis/silo/SiloClientTest.kt index 030cfcd2..a1e10bc8 100644 --- a/lapis2/src/test/kotlin/org/genspectrum/lapis/silo/SiloClientTest.kt +++ b/lapis2/src/test/kotlin/org/genspectrum/lapis/silo/SiloClientTest.kt @@ -453,7 +453,6 @@ class SiloClientTest( companion object { @JvmStatic val queriesThatShouldNotBeCached = listOf( - SiloQuery(SiloAction.aggregated(), True), SiloQuery(SiloAction.details(), True), SiloQuery(SiloAction.genomicSequence(SequenceType.ALIGNED, "sequenceName"), True), SiloQuery(SiloAction.genomicSequence(SequenceType.UNALIGNED, "sequenceName"), True), @@ -461,6 +460,7 @@ class SiloClientTest( @JvmStatic val queriesThatShouldBeCached = listOf( + SiloQuery(SiloAction.aggregated(), True), SiloQuery(SiloAction.mutations(), True), SiloQuery(SiloAction.aminoAcidMutations(), True), SiloQuery(SiloAction.nucleotideInsertions(), True), @@ -479,7 +479,6 @@ class SiloClientAndCacheInvalidatorTest( private lateinit var mockServer: ClientAndServer val someQuery = SiloQuery(SiloAction.mutations(), True) - val anotherQuery = SiloQuery(SiloAction.aminoAcidMutations(), True) val firstDataVersion = "1" val secondDataVersion = "2"