Skip to content

Commit 1edfd98

Browse files
authored
Bump incubating cache in benchmarks (#6795)
1 parent 2bfcd99 commit 1edfd98

File tree

6 files changed

+23
-9
lines changed

6 files changed

+23
-9
lines changed

benchmark/microbenchmark/src/androidTest/java/com/apollographql/apollo/benchmark/ApolloStoreIncubatingTests.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import com.apollographql.apollo.benchmark.Utils.operationBasedQuery
99
import com.apollographql.apollo.benchmark.Utils.resource
1010
import com.apollographql.apollo.benchmark.test.R
1111
import com.apollographql.cache.normalized.CacheManager
12+
import com.apollographql.cache.normalized.api.DefaultCacheKeyGenerator
13+
import com.apollographql.cache.normalized.api.DefaultCacheResolver
1214
import com.apollographql.cache.normalized.memory.MemoryCacheFactory
1315
import com.apollographql.cache.normalized.api.NormalizedCacheFactory
1416
import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory
@@ -65,7 +67,7 @@ class ApolloStoreIncubatingTests {
6567
}
6668

6769
private fun createCacheManager(cacheFactory: NormalizedCacheFactory): CacheManager {
68-
return CacheManager(cacheFactory)
70+
return CacheManager(cacheFactory, cacheKeyGenerator = DefaultCacheKeyGenerator, cacheResolver = DefaultCacheResolver)
6971
}
7072

7173

benchmark/microbenchmark/src/androidTest/java/com/apollographql/apollo/benchmark/CacheIncubatingIntegrationTests.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import com.apollographql.mockserver.MockServerHandler
2020
import com.apollographql.apollo.testing.MapTestNetworkTransport
2121
import com.apollographql.apollo.testing.registerTestResponse
2222
import com.apollographql.cache.normalized.CacheManager
23+
import com.apollographql.cache.normalized.api.DefaultCacheKeyGenerator
24+
import com.apollographql.cache.normalized.api.DefaultCacheResolver
2325
import com.apollographql.cache.normalized.api.NormalizedCacheFactory
2426
import com.apollographql.cache.normalized.cacheManager
2527
import com.apollographql.cache.normalized.memory.MemoryCacheFactory
@@ -101,7 +103,7 @@ class CacheIncubatingIntegrationTests {
101103
}
102104

103105
private fun createCacheManager(cacheFactory: NormalizedCacheFactory): CacheManager {
104-
return CacheManager(cacheFactory)
106+
return CacheManager(cacheFactory, cacheKeyGenerator = DefaultCacheKeyGenerator, cacheResolver = DefaultCacheResolver)
105107
}
106108

107109

benchmark/microbenchmark/src/androidTest/java/com/apollographql/apollo/benchmark/CacheIncubatingTests.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import com.apollographql.apollo.benchmark.Utils.resource
1414
import com.apollographql.apollo.benchmark.Utils.responseBasedQuery
1515
import com.apollographql.apollo.benchmark.test.R
1616
import com.apollographql.cache.normalized.CacheManager
17+
import com.apollographql.cache.normalized.api.DefaultCacheKeyGenerator
18+
import com.apollographql.cache.normalized.api.DefaultCacheResolver
1719
import com.apollographql.cache.normalized.memory.MemoryCacheFactory
1820
import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory
1921
import kotlinx.coroutines.runBlocking
@@ -61,7 +63,9 @@ class CacheIncubatingTests {
6163
SqlNormalizedCacheFactory(name = dbName)
6264
} else {
6365
MemoryCacheFactory()
64-
}
66+
},
67+
cacheKeyGenerator = DefaultCacheKeyGenerator,
68+
cacheResolver = DefaultCacheResolver,
6569
)
6670

6771
val data = query.parseJsonResponse(resource(jsonResponseResId).jsonReader()).data!!

benchmark/microbenchmark/src/androidTest/java/com/apollographql/apollo/benchmark/GarbageCollectTests.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ package com.apollographql.apollo.benchmark
22

33
import androidx.benchmark.junit4.BenchmarkRule
44
import androidx.benchmark.junit4.measureRepeated
5+
import com.apollographql.apollo.ApolloClient
56
import com.apollographql.apollo.benchmark.Utils.dbFile
67
import com.apollographql.apollo.benchmark.Utils.dbName
78
import com.apollographql.apollo.conferences.cache.Cache
8-
import com.apollographql.cache.normalized.ApolloStore
9+
import com.apollographql.apollo.conferences.cache.Cache.cache
910
import com.apollographql.cache.normalized.CacheManager
11+
import com.apollographql.cache.normalized.api.NormalizedCacheFactory
1012
import com.apollographql.cache.normalized.api.SchemaCoordinatesMaxAgeProvider
13+
import com.apollographql.cache.normalized.apolloStore
1114
import com.apollographql.cache.normalized.garbageCollect
1215
import com.apollographql.cache.normalized.memory.MemoryCacheFactory
1316
import com.apollographql.cache.normalized.sql.SqlNormalizedCacheFactory
@@ -25,7 +28,7 @@ class GarbageCollectTests {
2528
lateinit var cacheManager: CacheManager
2629
benchmarkRule.measureRepeated {
2730
runWithTimingDisabled {
28-
cacheManager = CacheManager(MemoryCacheFactory())
31+
cacheManager = cacheManager(MemoryCacheFactory())
2932
primeCache(cacheManager)
3033
}
3134
runBlocking {
@@ -42,7 +45,7 @@ class GarbageCollectTests {
4245
benchmarkRule.measureRepeated {
4346
runWithTimingDisabled {
4447
dbFile.delete()
45-
cacheManager = CacheManager(SqlNormalizedCacheFactory(dbName))
48+
cacheManager = cacheManager(SqlNormalizedCacheFactory(dbName))
4649
primeCache(cacheManager)
4750
}
4851
runBlocking {
@@ -59,7 +62,7 @@ class GarbageCollectTests {
5962
benchmarkRule.measureRepeated {
6063
runWithTimingDisabled {
6164
dbFile.delete()
62-
cacheManager = CacheManager(MemoryCacheFactory().chain(SqlNormalizedCacheFactory(dbName)))
65+
cacheManager = cacheManager(MemoryCacheFactory().chain(SqlNormalizedCacheFactory(dbName)))
6366
primeCache(cacheManager)
6467
}
6568
runBlocking {
@@ -71,6 +74,9 @@ class GarbageCollectTests {
7174
}
7275
}
7376

77+
private fun cacheManager(factory: NormalizedCacheFactory): CacheManager =
78+
ApolloClient.Builder().cache(factory).serverUrl("http://unused").build().apolloStore.cacheManager
79+
7480
private val maxAgeProvider = SchemaCoordinatesMaxAgeProvider(
7581
Cache.maxAges,
7682
defaultMaxAge = 1.days,

benchmark/microbenchmark/src/main/graphql/conferences/extra.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extend schema
55
)
66

77
@link(
8-
url: "https://specs.apollo.dev/cache/v0.1",
8+
url: "https://specs.apollo.dev/cache/v0.3",
99
import: ["@cacheControl", "@cacheControlField"]
1010
)
1111

gradle/libraries.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ androidx-sqlite = "2.6.0"
1313
# This is used by the Gradle integration tests to get the artifacts locally
1414
apollo = "5.0.0-alpha.4-SNAPSHOT"
1515
apollo-execution = "0.1.1"
16-
apollo-normalizedcache-incubating = "1.0.0-alpha.6"
16+
apollo-normalizedcache-incubating = "1.0.0-alpha.8"
1717
# Used by the apollo-tooling project which uses a published version of Apollo
1818
apollo-published = "4.3.3"
1919
#noinspection NewerVersionAvailable requires KGP 2.2

0 commit comments

Comments
 (0)