From d9e3a4643379706c310b027b13b2875de484cfbe Mon Sep 17 00:00:00 2001 From: BoD Date: Wed, 23 Apr 2025 12:56:33 +0200 Subject: [PATCH] Rename clearAll -> removeAll --- CHANGELOG.md | 2 ++ Writerside/topics/migration-guide.md | 1 + .../api/android/normalized-cache-sqlite.api | 1 + .../api/jvm/normalized-cache-sqlite.api | 1 + .../api/normalized-cache-sqlite.klib.api | 2 +- .../normalized/sql/SqlNormalizedCache.kt | 2 +- .../normalized/sql/SqlNormalizedCacheTest.kt | 6 +++--- .../cache/normalized/sql/TrimTest.kt | 2 +- normalized-cache/api/normalized-cache.api | 6 ++++++ .../api/normalized-cache.klib.api | 9 ++++++--- .../cache/normalized/ApolloStore.kt | 9 ++++++--- .../cache/normalized/SimpleApolloStore.kt | 7 +++++-- .../cache/normalized/api/NormalizedCache.kt | 7 +++++-- .../normalized/internal/DefaultApolloStore.kt | 4 ++-- .../internal/OptimisticNormalizedCache.kt | 4 ++-- .../cache/normalized/memory/MemoryCache.kt | 4 ++-- .../cache/normalized/MemoryCacheTest.kt | 2 +- .../ClientAndServerSideCacheControlTest.kt | 6 +++--- .../kotlin/ClientSideCacheControlTest.kt | 6 +++--- .../src/commonTest/kotlin/DoNotStoreTest.kt | 4 ++-- .../kotlin/ServerSideCacheControlTest.kt | 2 +- .../kotlin/DanglingReferencesTest.kt | 4 ++-- .../commonTest/kotlin/GarbageCollectTest.kt | 2 +- .../kotlin/ReachableCacheKeysTest.kt | 2 +- .../src/commonTest/kotlin/StaleFieldsTest.kt | 6 +++--- .../src/commonTest/kotlin/MigrationTest.kt | 4 ++-- .../com/example/SqlNormalizationTest.kt | 2 +- .../src/commonTest/kotlin/FetchPolicyTest.kt | 20 +++++++++---------- .../src/commonTest/kotlin/ThreadTests.kt | 4 ++-- .../src/commonTest/kotlin/WatcherTest.kt | 2 +- .../kotlin/MemoryCacheOnlyTest.kt | 4 ++-- .../kotlin/ConnectionPaginationTest.kt | 4 ++-- .../ConnectionProgrammaticPaginationTest.kt | 2 +- .../ConnectionWithNodesPaginationTest.kt | 2 +- .../kotlin/CursorBasedPaginationTest.kt | 2 +- .../OffsetBasedWithArrayPaginationTest.kt | 2 +- ...fsetBasedWithPageAndInputPaginationTest.kt | 2 +- .../OffsetBasedWithPagePaginationTest.kt | 2 +- .../commonTest/kotlin/test/StoreErrorsTest.kt | 4 ++-- 39 files changed, 90 insertions(+), 67 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5778c2f8..da76babd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ PUT_CHANGELOG_HERE +- Deprecate `ApolloStore`/`NormalizedCache` `clearAll()` in favor of `removeAll()` for consistency with `remove()` + # Version 0.0.9 _2025-04-09_ diff --git a/Writerside/topics/migration-guide.md b/Writerside/topics/migration-guide.md index 9789cf64..e18c6b3d 100644 --- a/Writerside/topics/migration-guide.md +++ b/Writerside/topics/migration-guide.md @@ -128,6 +128,7 @@ client.apolloStore.writeOperation( - `readFragment()` now returns a `ReadResult` (it previously returned a ``). This allows for surfacing metadata associated to the returned data, e.g. staleness. - Records are now rooted per operation type (`QUERY_ROOT`, `MUTATION_ROOT`, `SUBSCRIPTION_ROOT`), when previously these were all at the same level, which could cause conflicts. - `ApolloClient.apolloStore` is deprecated in favor of `ApolloClient.store` for consistency. +- `ApolloStore` / `NormalizedCache` `clearAll()` are deprecated in favor of `removeAll()` for consistency with `remove()`. ## CacheResolver, CacheKeyResolver diff --git a/normalized-cache-sqlite/api/android/normalized-cache-sqlite.api b/normalized-cache-sqlite/api/android/normalized-cache-sqlite.api index 8adc0fe0..edc8f81d 100644 --- a/normalized-cache-sqlite/api/android/normalized-cache-sqlite.api +++ b/normalized-cache-sqlite/api/android/normalized-cache-sqlite.api @@ -18,6 +18,7 @@ public final class com/apollographql/cache/normalized/sql/SqlNormalizedCache : c public fun merge (Ljava/util/Collection;Lcom/apollographql/cache/normalized/api/CacheHeaders;Lcom/apollographql/cache/normalized/api/RecordMerger;)Ljava/util/Set; public fun remove (Ljava/util/Collection;Z)I public fun remove-eNSUWrY (Ljava/lang/String;Z)Z + public fun removeAll ()V public fun trim (JF)J } diff --git a/normalized-cache-sqlite/api/jvm/normalized-cache-sqlite.api b/normalized-cache-sqlite/api/jvm/normalized-cache-sqlite.api index de11d7e4..470918a3 100644 --- a/normalized-cache-sqlite/api/jvm/normalized-cache-sqlite.api +++ b/normalized-cache-sqlite/api/jvm/normalized-cache-sqlite.api @@ -7,6 +7,7 @@ public final class com/apollographql/cache/normalized/sql/SqlNormalizedCache : c public fun merge (Ljava/util/Collection;Lcom/apollographql/cache/normalized/api/CacheHeaders;Lcom/apollographql/cache/normalized/api/RecordMerger;)Ljava/util/Set; public fun remove (Ljava/util/Collection;Z)I public fun remove-eNSUWrY (Ljava/lang/String;Z)Z + public fun removeAll ()V public fun trim (JF)J } diff --git a/normalized-cache-sqlite/api/normalized-cache-sqlite.klib.api b/normalized-cache-sqlite/api/normalized-cache-sqlite.klib.api index 7f22099b..5d0b0521 100644 --- a/normalized-cache-sqlite/api/normalized-cache-sqlite.klib.api +++ b/normalized-cache-sqlite/api/normalized-cache-sqlite.klib.api @@ -85,7 +85,6 @@ final class com.apollographql.cache.normalized.sql.internal.record/SelectRecords } final class com.apollographql.cache.normalized.sql/SqlNormalizedCache : com.apollographql.cache.normalized.api/NormalizedCache { // com.apollographql.cache.normalized.sql/SqlNormalizedCache|null[0] - final fun clearAll() // com.apollographql.cache.normalized.sql/SqlNormalizedCache.clearAll|clearAll(){}[0] final fun dump(): kotlin.collections/Map, kotlin.collections/Map> // com.apollographql.cache.normalized.sql/SqlNormalizedCache.dump|dump(){}[0] final fun loadRecord(com.apollographql.cache.normalized.api/CacheKey, com.apollographql.cache.normalized.api/CacheHeaders): com.apollographql.cache.normalized.api/Record? // com.apollographql.cache.normalized.sql/SqlNormalizedCache.loadRecord|loadRecord(com.apollographql.cache.normalized.api.CacheKey;com.apollographql.cache.normalized.api.CacheHeaders){}[0] final fun loadRecords(kotlin.collections/Collection, com.apollographql.cache.normalized.api/CacheHeaders): kotlin.collections/Collection // com.apollographql.cache.normalized.sql/SqlNormalizedCache.loadRecords|loadRecords(kotlin.collections.Collection;com.apollographql.cache.normalized.api.CacheHeaders){}[0] @@ -93,6 +92,7 @@ final class com.apollographql.cache.normalized.sql/SqlNormalizedCache : com.apol final fun merge(kotlin.collections/Collection, com.apollographql.cache.normalized.api/CacheHeaders, com.apollographql.cache.normalized.api/RecordMerger): kotlin.collections/Set // com.apollographql.cache.normalized.sql/SqlNormalizedCache.merge|merge(kotlin.collections.Collection;com.apollographql.cache.normalized.api.CacheHeaders;com.apollographql.cache.normalized.api.RecordMerger){}[0] final fun remove(com.apollographql.cache.normalized.api/CacheKey, kotlin/Boolean): kotlin/Boolean // com.apollographql.cache.normalized.sql/SqlNormalizedCache.remove|remove(com.apollographql.cache.normalized.api.CacheKey;kotlin.Boolean){}[0] final fun remove(kotlin.collections/Collection, kotlin/Boolean): kotlin/Int // com.apollographql.cache.normalized.sql/SqlNormalizedCache.remove|remove(kotlin.collections.Collection;kotlin.Boolean){}[0] + final fun removeAll() // com.apollographql.cache.normalized.sql/SqlNormalizedCache.removeAll|removeAll(){}[0] final fun trim(kotlin/Long, kotlin/Float): kotlin/Long // com.apollographql.cache.normalized.sql/SqlNormalizedCache.trim|trim(kotlin.Long;kotlin.Float){}[0] } diff --git a/normalized-cache-sqlite/src/commonMain/kotlin/com/apollographql/cache/normalized/sql/SqlNormalizedCache.kt b/normalized-cache-sqlite/src/commonMain/kotlin/com/apollographql/cache/normalized/sql/SqlNormalizedCache.kt index 131f7b72..ea2cbb0a 100644 --- a/normalized-cache-sqlite/src/commonMain/kotlin/com/apollographql/cache/normalized/sql/SqlNormalizedCache.kt +++ b/normalized-cache-sqlite/src/commonMain/kotlin/com/apollographql/cache/normalized/sql/SqlNormalizedCache.kt @@ -34,7 +34,7 @@ class SqlNormalizedCache internal constructor( } } - override fun clearAll() { + override fun removeAll() { recordDatabase.deleteAllRecords() } diff --git a/normalized-cache-sqlite/src/commonTest/kotlin/com/apollographql/cache/normalized/sql/SqlNormalizedCacheTest.kt b/normalized-cache-sqlite/src/commonTest/kotlin/com/apollographql/cache/normalized/sql/SqlNormalizedCacheTest.kt index 64b4285b..aaec965b 100644 --- a/normalized-cache-sqlite/src/commonTest/kotlin/com/apollographql/cache/normalized/sql/SqlNormalizedCacheTest.kt +++ b/normalized-cache-sqlite/src/commonTest/kotlin/com/apollographql/cache/normalized/sql/SqlNormalizedCacheTest.kt @@ -28,7 +28,7 @@ class SqlNormalizedCacheTest { @BeforeTest fun setUp() { - cache.clearAll() + cache.removeAll() } @Test @@ -114,10 +114,10 @@ class SqlNormalizedCacheTest { } @Test - fun testClearAll() { + fun testRemoveAll() { createRecord(QUERY_ROOT_KEY) createRecord(STANDARD_KEY) - cache.clearAll() + cache.removeAll() assertNull(cache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE)) assertNull(cache.loadRecord(STANDARD_KEY, CacheHeaders.NONE)) } diff --git a/normalized-cache-sqlite/src/commonTest/kotlin/com/apollographql/cache/normalized/sql/TrimTest.kt b/normalized-cache-sqlite/src/commonTest/kotlin/com/apollographql/cache/normalized/sql/TrimTest.kt index c224136a..6ace87a0 100644 --- a/normalized-cache-sqlite/src/commonTest/kotlin/com/apollographql/cache/normalized/sql/TrimTest.kt +++ b/normalized-cache-sqlite/src/commonTest/kotlin/com/apollographql/cache/normalized/sql/TrimTest.kt @@ -13,7 +13,7 @@ import kotlin.test.assertNull class TrimTest { @Test fun trimTest() { - val apolloStore = ApolloStore(SqlNormalizedCacheFactory()).also { it.clearAll() } + val apolloStore = ApolloStore(SqlNormalizedCacheFactory()).also { it.removeAll() } val largeString = "".padStart(1024, '?') diff --git a/normalized-cache/api/normalized-cache.api b/normalized-cache/api/normalized-cache.api index b6eb8c96..a6cbcd06 100644 --- a/normalized-cache/api/normalized-cache.api +++ b/normalized-cache/api/normalized-cache.api @@ -11,6 +11,7 @@ public abstract interface class com/apollographql/cache/normalized/ApolloStore { public abstract fun readOperation (Lcom/apollographql/apollo/api/Operation;Lcom/apollographql/apollo/api/CustomScalarAdapters;Lcom/apollographql/cache/normalized/api/CacheHeaders;)Lcom/apollographql/apollo/api/ApolloResponse; public abstract fun remove (Ljava/util/List;Z)I public abstract fun remove-eNSUWrY (Ljava/lang/String;Z)Z + public abstract fun removeAll ()Z public abstract fun rollbackOptimisticUpdates (Ljava/util/UUID;)Ljava/util/Set; public abstract fun trim (JF)J public abstract fun writeFragment-1qdIjGk (Lcom/apollographql/apollo/api/Fragment;Ljava/lang/String;Lcom/apollographql/apollo/api/Fragment$Data;Lcom/apollographql/apollo/api/CustomScalarAdapters;Lcom/apollographql/cache/normalized/api/CacheHeaders;)Ljava/util/Set; @@ -25,6 +26,7 @@ public final class com/apollographql/cache/normalized/ApolloStore$Companion { } public final class com/apollographql/cache/normalized/ApolloStore$DefaultImpls { + public static fun clearAll (Lcom/apollographql/cache/normalized/ApolloStore;)Z public static synthetic fun normalize-niOPdRo$default (Lcom/apollographql/cache/normalized/ApolloStore;Lcom/apollographql/apollo/api/Executable;Ljava/util/Map;Ljava/lang/String;Lcom/apollographql/apollo/api/CustomScalarAdapters;ILjava/lang/Object;)Ljava/util/Map; public static synthetic fun readFragment-dEpVOtE$default (Lcom/apollographql/cache/normalized/ApolloStore;Lcom/apollographql/apollo/api/Fragment;Ljava/lang/String;Lcom/apollographql/apollo/api/CustomScalarAdapters;Lcom/apollographql/cache/normalized/api/CacheHeaders;ILjava/lang/Object;)Lcom/apollographql/cache/normalized/ApolloStore$ReadResult; public static synthetic fun readOperation$default (Lcom/apollographql/cache/normalized/ApolloStore;Lcom/apollographql/apollo/api/Operation;Lcom/apollographql/apollo/api/CustomScalarAdapters;Lcom/apollographql/cache/normalized/api/CacheHeaders;ILjava/lang/Object;)Lcom/apollographql/apollo/api/ApolloResponse; @@ -202,6 +204,7 @@ public final class com/apollographql/cache/normalized/SimpleApolloStore { public static synthetic fun remove$default (Lcom/apollographql/cache/normalized/SimpleApolloStore;Ljava/util/List;ZILjava/lang/Object;)I public final fun remove-eNSUWrY (Ljava/lang/String;Z)Z public static synthetic fun remove-eNSUWrY$default (Lcom/apollographql/cache/normalized/SimpleApolloStore;Ljava/lang/String;ZILjava/lang/Object;)Z + public final fun removeAll ()Z public final fun rollbackOptimisticUpdates (Ljava/util/UUID;)Ljava/util/Set; public final fun trim (JF)J public static synthetic fun trim$default (Lcom/apollographql/cache/normalized/SimpleApolloStore;JFILjava/lang/Object;)J @@ -495,6 +498,7 @@ public abstract interface class com/apollographql/cache/normalized/api/Normalize public static fun prettifyDump (Ljava/util/Map;)Ljava/lang/String; public abstract fun remove (Ljava/util/Collection;Z)I public abstract fun remove-eNSUWrY (Ljava/lang/String;Z)Z + public abstract fun removeAll ()V public abstract fun trim (JF)J } @@ -503,6 +507,7 @@ public final class com/apollographql/cache/normalized/api/NormalizedCache$Compan } public final class com/apollographql/cache/normalized/api/NormalizedCache$DefaultImpls { + public static fun clearAll (Lcom/apollographql/cache/normalized/api/NormalizedCache;)V public static fun trim (Lcom/apollographql/cache/normalized/api/NormalizedCache;JF)J public static synthetic fun trim$default (Lcom/apollographql/cache/normalized/api/NormalizedCache;JFILjava/lang/Object;)J } @@ -634,6 +639,7 @@ public final class com/apollographql/cache/normalized/memory/MemoryCache : com/a public fun merge (Ljava/util/Collection;Lcom/apollographql/cache/normalized/api/CacheHeaders;Lcom/apollographql/cache/normalized/api/RecordMerger;)Ljava/util/Set; public fun remove (Ljava/util/Collection;Z)I public fun remove-eNSUWrY (Ljava/lang/String;Z)Z + public fun removeAll ()V public fun trim (JF)J } diff --git a/normalized-cache/api/normalized-cache.klib.api b/normalized-cache/api/normalized-cache.klib.api index e119a291..8481d92e 100644 --- a/normalized-cache/api/normalized-cache.klib.api +++ b/normalized-cache/api/normalized-cache.klib.api @@ -54,11 +54,12 @@ abstract interface com.apollographql.cache.normalized.api/MetadataGenerator { // } abstract interface com.apollographql.cache.normalized.api/NormalizedCache : com.apollographql.cache.normalized.api/ReadOnlyNormalizedCache { // com.apollographql.cache.normalized.api/NormalizedCache|null[0] - abstract fun clearAll() // com.apollographql.cache.normalized.api/NormalizedCache.clearAll|clearAll(){}[0] abstract fun merge(com.apollographql.cache.normalized.api/Record, com.apollographql.cache.normalized.api/CacheHeaders, com.apollographql.cache.normalized.api/RecordMerger): kotlin.collections/Set // com.apollographql.cache.normalized.api/NormalizedCache.merge|merge(com.apollographql.cache.normalized.api.Record;com.apollographql.cache.normalized.api.CacheHeaders;com.apollographql.cache.normalized.api.RecordMerger){}[0] abstract fun merge(kotlin.collections/Collection, com.apollographql.cache.normalized.api/CacheHeaders, com.apollographql.cache.normalized.api/RecordMerger): kotlin.collections/Set // com.apollographql.cache.normalized.api/NormalizedCache.merge|merge(kotlin.collections.Collection;com.apollographql.cache.normalized.api.CacheHeaders;com.apollographql.cache.normalized.api.RecordMerger){}[0] abstract fun remove(com.apollographql.cache.normalized.api/CacheKey, kotlin/Boolean): kotlin/Boolean // com.apollographql.cache.normalized.api/NormalizedCache.remove|remove(com.apollographql.cache.normalized.api.CacheKey;kotlin.Boolean){}[0] abstract fun remove(kotlin.collections/Collection, kotlin/Boolean): kotlin/Int // com.apollographql.cache.normalized.api/NormalizedCache.remove|remove(kotlin.collections.Collection;kotlin.Boolean){}[0] + abstract fun removeAll() // com.apollographql.cache.normalized.api/NormalizedCache.removeAll|removeAll(){}[0] + open fun clearAll() // com.apollographql.cache.normalized.api/NormalizedCache.clearAll|clearAll(){}[0] open fun trim(kotlin/Long, kotlin/Float = ...): kotlin/Long // com.apollographql.cache.normalized.api/NormalizedCache.trim|trim(kotlin.Long;kotlin.Float){}[0] final object Companion { // com.apollographql.cache.normalized.api/NormalizedCache.Companion|null[0] @@ -89,14 +90,15 @@ abstract interface com.apollographql.cache.normalized/ApolloStore { // com.apoll abstract fun <#A1: com.apollographql.apollo.api/Operation.Data> writeOperation(com.apollographql.apollo.api/Operation<#A1>, kotlin.collections/Map, com.apollographql.apollo.api/CustomScalarAdapters = ..., com.apollographql.cache.normalized.api/CacheHeaders = ...): kotlin.collections/Set // com.apollographql.cache.normalized/ApolloStore.writeOperation|writeOperation(com.apollographql.apollo.api.Operation<0:0>;kotlin.collections.Map;com.apollographql.apollo.api.CustomScalarAdapters;com.apollographql.cache.normalized.api.CacheHeaders){0§}[0] abstract fun <#A1: com.apollographql.apollo.api/Operation.Data> writeOptimisticUpdates(com.apollographql.apollo.api/Operation<#A1>, #A1, com.benasher44.uuid/Uuid, com.apollographql.apollo.api/CustomScalarAdapters = ...): kotlin.collections/Set // com.apollographql.cache.normalized/ApolloStore.writeOptimisticUpdates|writeOptimisticUpdates(com.apollographql.apollo.api.Operation<0:0>;0:0;com.benasher44.uuid.Uuid;com.apollographql.apollo.api.CustomScalarAdapters){0§}[0] abstract fun <#A1: kotlin/Any?> accessCache(kotlin/Function1): #A1 // com.apollographql.cache.normalized/ApolloStore.accessCache|accessCache(kotlin.Function1){0§}[0] - abstract fun clearAll(): kotlin/Boolean // com.apollographql.cache.normalized/ApolloStore.clearAll|clearAll(){}[0] abstract fun dispose() // com.apollographql.cache.normalized/ApolloStore.dispose|dispose(){}[0] abstract fun dump(): kotlin.collections/Map, kotlin.collections/Map> // com.apollographql.cache.normalized/ApolloStore.dump|dump(){}[0] abstract fun remove(com.apollographql.cache.normalized.api/CacheKey, kotlin/Boolean = ...): kotlin/Boolean // com.apollographql.cache.normalized/ApolloStore.remove|remove(com.apollographql.cache.normalized.api.CacheKey;kotlin.Boolean){}[0] abstract fun remove(kotlin.collections/List, kotlin/Boolean = ...): kotlin/Int // com.apollographql.cache.normalized/ApolloStore.remove|remove(kotlin.collections.List;kotlin.Boolean){}[0] + abstract fun removeAll(): kotlin/Boolean // com.apollographql.cache.normalized/ApolloStore.removeAll|removeAll(){}[0] abstract fun rollbackOptimisticUpdates(com.benasher44.uuid/Uuid): kotlin.collections/Set // com.apollographql.cache.normalized/ApolloStore.rollbackOptimisticUpdates|rollbackOptimisticUpdates(com.benasher44.uuid.Uuid){}[0] abstract fun trim(kotlin/Long, kotlin/Float = ...): kotlin/Long // com.apollographql.cache.normalized/ApolloStore.trim|trim(kotlin.Long;kotlin.Float){}[0] abstract suspend fun publish(kotlin.collections/Set) // com.apollographql.cache.normalized/ApolloStore.publish|publish(kotlin.collections.Set){}[0] + open fun clearAll(): kotlin/Boolean // com.apollographql.cache.normalized/ApolloStore.clearAll|clearAll(){}[0] final class <#A1: com.apollographql.apollo.api/Executable.Data> ReadResult { // com.apollographql.cache.normalized/ApolloStore.ReadResult|null[0] constructor (#A1, com.apollographql.cache.normalized.api/CacheHeaders) // com.apollographql.cache.normalized/ApolloStore.ReadResult.|(1:0;com.apollographql.cache.normalized.api.CacheHeaders){}[0] @@ -384,7 +386,6 @@ final class com.apollographql.cache.normalized.memory/MemoryCache : com.apollogr final val size // com.apollographql.cache.normalized.memory/MemoryCache.size|{}size[0] final fun (): kotlin/Int // com.apollographql.cache.normalized.memory/MemoryCache.size.|(){}[0] - final fun clearAll() // com.apollographql.cache.normalized.memory/MemoryCache.clearAll|clearAll(){}[0] final fun dump(): kotlin.collections/Map, kotlin.collections/Map> // com.apollographql.cache.normalized.memory/MemoryCache.dump|dump(){}[0] final fun loadRecord(com.apollographql.cache.normalized.api/CacheKey, com.apollographql.cache.normalized.api/CacheHeaders): com.apollographql.cache.normalized.api/Record? // com.apollographql.cache.normalized.memory/MemoryCache.loadRecord|loadRecord(com.apollographql.cache.normalized.api.CacheKey;com.apollographql.cache.normalized.api.CacheHeaders){}[0] final fun loadRecords(kotlin.collections/Collection, com.apollographql.cache.normalized.api/CacheHeaders): kotlin.collections/Collection // com.apollographql.cache.normalized.memory/MemoryCache.loadRecords|loadRecords(kotlin.collections.Collection;com.apollographql.cache.normalized.api.CacheHeaders){}[0] @@ -392,6 +393,7 @@ final class com.apollographql.cache.normalized.memory/MemoryCache : com.apollogr final fun merge(kotlin.collections/Collection, com.apollographql.cache.normalized.api/CacheHeaders, com.apollographql.cache.normalized.api/RecordMerger): kotlin.collections/Set // com.apollographql.cache.normalized.memory/MemoryCache.merge|merge(kotlin.collections.Collection;com.apollographql.cache.normalized.api.CacheHeaders;com.apollographql.cache.normalized.api.RecordMerger){}[0] final fun remove(com.apollographql.cache.normalized.api/CacheKey, kotlin/Boolean): kotlin/Boolean // com.apollographql.cache.normalized.memory/MemoryCache.remove|remove(com.apollographql.cache.normalized.api.CacheKey;kotlin.Boolean){}[0] final fun remove(kotlin.collections/Collection, kotlin/Boolean): kotlin/Int // com.apollographql.cache.normalized.memory/MemoryCache.remove|remove(kotlin.collections.Collection;kotlin.Boolean){}[0] + final fun removeAll() // com.apollographql.cache.normalized.memory/MemoryCache.removeAll|removeAll(){}[0] final fun trim(kotlin/Long, kotlin/Float): kotlin/Long // com.apollographql.cache.normalized.memory/MemoryCache.trim|trim(kotlin.Long;kotlin.Float){}[0] } @@ -490,6 +492,7 @@ final class com.apollographql.cache.normalized/SimpleApolloStore { // com.apollo final fun dump(): kotlin.collections/Map, kotlin.collections/Map> // com.apollographql.cache.normalized/SimpleApolloStore.dump|dump(){}[0] final fun remove(com.apollographql.cache.normalized.api/CacheKey, kotlin/Boolean = ...): kotlin/Boolean // com.apollographql.cache.normalized/SimpleApolloStore.remove|remove(com.apollographql.cache.normalized.api.CacheKey;kotlin.Boolean){}[0] final fun remove(kotlin.collections/List, kotlin/Boolean = ...): kotlin/Int // com.apollographql.cache.normalized/SimpleApolloStore.remove|remove(kotlin.collections.List;kotlin.Boolean){}[0] + final fun removeAll(): kotlin/Boolean // com.apollographql.cache.normalized/SimpleApolloStore.removeAll|removeAll(){}[0] final fun rollbackOptimisticUpdates(com.benasher44.uuid/Uuid): kotlin.collections/Set // com.apollographql.cache.normalized/SimpleApolloStore.rollbackOptimisticUpdates|rollbackOptimisticUpdates(com.benasher44.uuid.Uuid){}[0] final fun trim(kotlin/Long, kotlin/Float = ...): kotlin/Long // com.apollographql.cache.normalized/SimpleApolloStore.trim|trim(kotlin.Long;kotlin.Float){}[0] final suspend fun publish(kotlin.collections/Set) // com.apollographql.cache.normalized/SimpleApolloStore.publish|publish(kotlin.collections.Set){}[0] diff --git a/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/ApolloStore.kt b/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/ApolloStore.kt index 0ece78f2..90da6ae6 100644 --- a/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/ApolloStore.kt +++ b/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/ApolloStore.kt @@ -210,13 +210,16 @@ interface ApolloStore { ): Set /** - * Clears all records. + * Removes all records. * * This is a synchronous operation that might block if the underlying cache is doing IO. * * @return `true` if all records were successfully removed, `false` otherwise */ - fun clearAll(): Boolean + fun removeAll(): Boolean + + @Deprecated("Use removeAll() instead", ReplaceWith("removeAll()")) + fun clearAll() = removeAll() /** * Removes a record by its key. @@ -266,7 +269,7 @@ interface ApolloStore { /** * Publishes a set of keys that have changed. This will notify subscribers of [changedKeys]. * - * Pass [ALL_KEYS] to indicate that all records have changed, for instance after a [clearAll] operation. + * Pass [ALL_KEYS] to indicate that all records have changed, for instance after a [removeAll] operation. * * @see changedKeys * diff --git a/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/SimpleApolloStore.kt b/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/SimpleApolloStore.kt index 5721dd6f..e51a138a 100644 --- a/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/SimpleApolloStore.kt +++ b/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/SimpleApolloStore.kt @@ -137,9 +137,12 @@ class SimpleApolloStore( fun rollbackOptimisticUpdates(mutationId: Uuid): Set = apolloStore.rollbackOptimisticUpdates(mutationId) /** - * @see ApolloStore.clearAll + * @see ApolloStore.removeAll */ - fun clearAll(): Boolean = apolloStore.clearAll() + fun removeAll(): Boolean = apolloStore.removeAll() + + @Deprecated("Use removeAll() instead", ReplaceWith("removeAll()")) + fun clearAll() = removeAll() /** * @see ApolloStore.remove diff --git a/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/api/NormalizedCache.kt b/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/api/NormalizedCache.kt index cfcf1387..0d7fa502 100644 --- a/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/api/NormalizedCache.kt +++ b/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/api/NormalizedCache.kt @@ -47,9 +47,12 @@ interface NormalizedCache : ReadOnlyNormalizedCache { /** - * Clears all records from the cache. + * Removes all records from the cache. */ - fun clearAll() + fun removeAll() + + @Deprecated("Use removeAll() instead", ReplaceWith("removeAll()")) + fun clearAll() = removeAll() /** * Remove a record and potentially its referenced records from this cache and all chained caches diff --git a/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/internal/DefaultApolloStore.kt b/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/internal/DefaultApolloStore.kt index d4e4e99b..d319485e 100644 --- a/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/internal/DefaultApolloStore.kt +++ b/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/internal/DefaultApolloStore.kt @@ -85,8 +85,8 @@ internal class DefaultApolloStore( changedKeysEvents.emit(keys) } - override fun clearAll(): Boolean { - cache.clearAll() + override fun removeAll(): Boolean { + cache.removeAll() return true } diff --git a/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/internal/OptimisticNormalizedCache.kt b/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/internal/OptimisticNormalizedCache.kt index 880e2dd8..07fd0549 100644 --- a/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/internal/OptimisticNormalizedCache.kt +++ b/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/internal/OptimisticNormalizedCache.kt @@ -33,8 +33,8 @@ internal class OptimisticNormalizedCache(private val wrapped: NormalizedCache) : return wrapped.merge(records, cacheHeaders, recordMerger) } - override fun clearAll() { - wrapped.clearAll() + override fun removeAll() { + wrapped.removeAll() recordJournals.clear() } diff --git a/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/memory/MemoryCache.kt b/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/memory/MemoryCache.kt index 41fdaed4..12d5b73b 100644 --- a/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/memory/MemoryCache.kt +++ b/normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/memory/MemoryCache.kt @@ -63,10 +63,10 @@ class MemoryCache( recordsByKey.values.filterNotNull() + nextCachedRecords } - override fun clearAll() { + override fun removeAll() { lockWrite { lruCache.clear() - nextCache?.clearAll() + nextCache?.removeAll() } } diff --git a/normalized-cache/src/commonTest/kotlin/com/apollographql/cache/normalized/MemoryCacheTest.kt b/normalized-cache/src/commonTest/kotlin/com/apollographql/cache/normalized/MemoryCacheTest.kt index b2fbb5b1..7f458a77 100644 --- a/normalized-cache/src/commonTest/kotlin/com/apollographql/cache/normalized/MemoryCacheTest.kt +++ b/normalized-cache/src/commonTest/kotlin/com/apollographql/cache/normalized/MemoryCacheTest.kt @@ -166,7 +166,7 @@ class MemoryCacheTest { val records = listOf(testRecord1, testRecord2, testRecord3) primaryCache.merge(records, CacheHeaders.NONE, DefaultRecordMerger) - primaryCache.clearAll() + primaryCache.removeAll() assertEquals(0, primaryCache.size) assertEquals(0, secondaryCache.size) diff --git a/tests/cache-control/src/commonTest/kotlin/ClientAndServerSideCacheControlTest.kt b/tests/cache-control/src/commonTest/kotlin/ClientAndServerSideCacheControlTest.kt index 157054ca..591b8c06 100644 --- a/tests/cache-control/src/commonTest/kotlin/ClientAndServerSideCacheControlTest.kt +++ b/tests/cache-control/src/commonTest/kotlin/ClientAndServerSideCacheControlTest.kt @@ -69,7 +69,7 @@ class ClientAndServerSideCacheControlTest { .storeExpirationDate(true) .serverUrl(mockServer.url()) .build() - client.store.clearAll() + client.store.removeAll() val data = """ { @@ -148,7 +148,7 @@ class ClientAndServerSideCacheControlTest { .storeExpirationDate(true) .serverUrl(mockServer.url()) .build() - client.store.clearAll() + client.store.removeAll() val data = """ { @@ -220,7 +220,7 @@ class ClientAndServerSideCacheControlTest { ) .serverUrl(mockServer.url()) .build() - client.store.clearAll() + client.store.removeAll() val data = """ { diff --git a/tests/cache-control/src/commonTest/kotlin/ClientSideCacheControlTest.kt b/tests/cache-control/src/commonTest/kotlin/ClientSideCacheControlTest.kt index 106efaba..3af527d5 100644 --- a/tests/cache-control/src/commonTest/kotlin/ClientSideCacheControlTest.kt +++ b/tests/cache-control/src/commonTest/kotlin/ClientSideCacheControlTest.kt @@ -85,7 +85,7 @@ class ClientSideCacheControlTest { ) .serverUrl("unused") .build() - client.store.clearAll() + client.store.removeAll() val query = GetUserQuery() val data = GetUserQuery.Data(GetUserQuery.User("John", "john@doe.com", true)) @@ -132,7 +132,7 @@ class ClientSideCacheControlTest { ) .serverUrl("unused") .build() - client.store.clearAll() + client.store.removeAll() // Store records 25 seconds ago, more than default max age: should cache miss mergeCompanyQueryResults(client, 25) @@ -200,7 +200,7 @@ class ClientSideCacheControlTest { ) .serverUrl("unused") .build() - client.store.clearAll() + client.store.removeAll() // Store records 25 seconds ago, more than default max age: should cache miss mergeCompanyQueryResults(client, 25) diff --git a/tests/cache-control/src/commonTest/kotlin/DoNotStoreTest.kt b/tests/cache-control/src/commonTest/kotlin/DoNotStoreTest.kt index 8b770d95..cfb05c71 100644 --- a/tests/cache-control/src/commonTest/kotlin/DoNotStoreTest.kt +++ b/tests/cache-control/src/commonTest/kotlin/DoNotStoreTest.kt @@ -99,7 +99,7 @@ class DoNotStoreTest { ) .build() .use { apolloClient -> - apolloClient.store.clearAll() + apolloClient.store.removeAll() val networkResponse = apolloClient.query(GetUserQuery()) .fetchPolicy(FetchPolicy.NetworkOnly) .execute() @@ -195,7 +195,7 @@ class DoNotStoreTest { ) .build() .use { apolloClient -> - apolloClient.store.clearAll() + apolloClient.store.removeAll() val networkResponse = apolloClient.mutation(SignInMutation("scott", "tiger")) .fetchPolicy(FetchPolicy.NetworkOnly) .execute() diff --git a/tests/cache-control/src/commonTest/kotlin/ServerSideCacheControlTest.kt b/tests/cache-control/src/commonTest/kotlin/ServerSideCacheControlTest.kt index 241f10e2..1ba69fea 100644 --- a/tests/cache-control/src/commonTest/kotlin/ServerSideCacheControlTest.kt +++ b/tests/cache-control/src/commonTest/kotlin/ServerSideCacheControlTest.kt @@ -48,7 +48,7 @@ class ServerSideCacheControlTest { .storeExpirationDate(true) .serverUrl(mockServer.url()) .build() - client.store.clearAll() + client.store.removeAll() val query = GetUserQuery() val data = """ diff --git a/tests/garbage-collection/src/commonTest/kotlin/DanglingReferencesTest.kt b/tests/garbage-collection/src/commonTest/kotlin/DanglingReferencesTest.kt index c9cfed79..382cf263 100644 --- a/tests/garbage-collection/src/commonTest/kotlin/DanglingReferencesTest.kt +++ b/tests/garbage-collection/src/commonTest/kotlin/DanglingReferencesTest.kt @@ -36,7 +36,7 @@ class DanglingReferencesTest { private fun simple(apolloStore: ApolloStore) = runTest { val mockServer = MockServer() - val store = apolloStore.also { it.clearAll() } + val store = apolloStore.also { it.removeAll() } ApolloClient.Builder() .serverUrl(mockServer.url()) .store(store) @@ -77,7 +77,7 @@ class DanglingReferencesTest { private fun multiple(apolloStore: ApolloStore) = runTest { val mockServer = MockServer() - val store = apolloStore.also { it.clearAll() } + val store = apolloStore.also { it.removeAll() } ApolloClient.Builder() .serverUrl(mockServer.url()) .store(store) diff --git a/tests/garbage-collection/src/commonTest/kotlin/GarbageCollectTest.kt b/tests/garbage-collection/src/commonTest/kotlin/GarbageCollectTest.kt index fe646c1a..0d10d0b8 100644 --- a/tests/garbage-collection/src/commonTest/kotlin/GarbageCollectTest.kt +++ b/tests/garbage-collection/src/commonTest/kotlin/GarbageCollectTest.kt @@ -35,7 +35,7 @@ class GarbageCollectTest { private fun garbageCollect(apolloStore: ApolloStore) = runTest { val mockServer = MockServer() - val store = apolloStore.also { it.clearAll() } + val store = apolloStore.also { it.removeAll() } ApolloClient.Builder() .serverUrl(mockServer.url()) .store(store) diff --git a/tests/garbage-collection/src/commonTest/kotlin/ReachableCacheKeysTest.kt b/tests/garbage-collection/src/commonTest/kotlin/ReachableCacheKeysTest.kt index 4c71f5e0..ba967bef 100644 --- a/tests/garbage-collection/src/commonTest/kotlin/ReachableCacheKeysTest.kt +++ b/tests/garbage-collection/src/commonTest/kotlin/ReachableCacheKeysTest.kt @@ -33,7 +33,7 @@ class ReachableCacheKeysTest { private fun getReachableCacheKeys(apolloStore: ApolloStore) = runTest { val mockServer = MockServer() - val store = apolloStore.also { it.clearAll() } + val store = apolloStore.also { it.removeAll() } ApolloClient.Builder() .serverUrl(mockServer.url()) .store(store) diff --git a/tests/garbage-collection/src/commonTest/kotlin/StaleFieldsTest.kt b/tests/garbage-collection/src/commonTest/kotlin/StaleFieldsTest.kt index 13f22189..aa432b93 100644 --- a/tests/garbage-collection/src/commonTest/kotlin/StaleFieldsTest.kt +++ b/tests/garbage-collection/src/commonTest/kotlin/StaleFieldsTest.kt @@ -43,7 +43,7 @@ class StaleFieldsTest { private fun clientControlledRemoveFields(apolloStore: ApolloStore) = runTest { val mockServer = MockServer() - val store = apolloStore.also { it.clearAll() } + val store = apolloStore.also { it.removeAll() } ApolloClient.Builder() .serverUrl(mockServer.url()) .store(store) @@ -120,7 +120,7 @@ class StaleFieldsTest { private fun clientControlledRemoveRecords(apolloStore: ApolloStore) = runTest { val mockServer = MockServer() - val store = apolloStore.also { it.clearAll() } + val store = apolloStore.also { it.removeAll() } ApolloClient.Builder() .serverUrl(mockServer.url()) .store(store) @@ -198,7 +198,7 @@ class StaleFieldsTest { private fun serverControlledRemoveFields(apolloStore: ApolloStore) = runTest { val mockServer = MockServer() - val store = apolloStore.also { it.clearAll() } + val store = apolloStore.also { it.removeAll() } ApolloClient.Builder() .serverUrl(mockServer.url()) .store(store) diff --git a/tests/migration/src/commonTest/kotlin/MigrationTest.kt b/tests/migration/src/commonTest/kotlin/MigrationTest.kt index eeb6c37d..d6f20875 100644 --- a/tests/migration/src/commonTest/kotlin/MigrationTest.kt +++ b/tests/migration/src/commonTest/kotlin/MigrationTest.kt @@ -116,7 +116,7 @@ class MigrationTest { assertEquals(REPOSITORY_LIST_DATA, response.data) // Clean up - store.clearAll() + store.removeAll() } } @@ -137,7 +137,7 @@ class MigrationTest { } // Create a modern store and migrate the legacy data - val store = ApolloStore(SqlNormalizedCacheFactory(name = "modern.db")).also { it.clearAll() } + val store = ApolloStore(SqlNormalizedCacheFactory(name = "modern.db")).also { it.removeAll() } store.migrateFrom(legacyStore) // Read the data back diff --git a/tests/normalization-tests/src/concurrentTest/kotlin/com/example/SqlNormalizationTest.kt b/tests/normalization-tests/src/concurrentTest/kotlin/com/example/SqlNormalizationTest.kt index 72a5d1b6..de4a7819 100644 --- a/tests/normalization-tests/src/concurrentTest/kotlin/com/example/SqlNormalizationTest.kt +++ b/tests/normalization-tests/src/concurrentTest/kotlin/com/example/SqlNormalizationTest.kt @@ -25,7 +25,7 @@ class SqlNormalizationTest { .normalizedCache(SqlNormalizedCacheFactory()) .build() - apolloClient.apolloStore.clearAll() + apolloClient.apolloStore.removeAll() mockserver.enqueueString( // language=JSON """ diff --git a/tests/normalized-cache/src/commonTest/kotlin/FetchPolicyTest.kt b/tests/normalized-cache/src/commonTest/kotlin/FetchPolicyTest.kt index d7931b97..1ea94101 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/FetchPolicyTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/FetchPolicyTest.kt @@ -92,7 +92,7 @@ class FetchPolicyTest { assertTrue(response.isFromCache) // Clear the store and offer a malformed response, we should get a composite error - store.clearAll() + store.removeAll() mockServer.enqueueString("malformed") apolloClient.query(query).execute().exception.let { assertIs(it) @@ -125,7 +125,7 @@ class FetchPolicyTest { assertTrue(response.isFromCache) // Clear the store and offer a malformed response, we should get a composite error - store.clearAll() + store.removeAll() mockServer.enqueueString("malformed") try { @Suppress("DEPRECATION") @@ -173,7 +173,7 @@ class FetchPolicyTest { } // Clear the store and offer a malformed response, we should get a composite error - store.clearAll() + store.removeAll() mockServer.enqueueString("malformed") @Suppress("DEPRECATION") responses = apolloClient.query(query) @@ -215,7 +215,7 @@ class FetchPolicyTest { // Network error and no cache -> we should get an error mockServer.enqueueString("malformed") - store.clearAll() + store.removeAll() call.execute().exception.let { assertIs(it) @@ -254,7 +254,7 @@ class FetchPolicyTest { // Network error and no cache -> we should get an error mockServer.enqueueString("malformed") - store.clearAll() + store.removeAll() try { @Suppress("DEPRECATION") call.executeV3() @@ -308,7 +308,7 @@ class FetchPolicyTest { // Network error and no cache -> we should get an error mockServer.enqueueString("malformed") - store.clearAll() + store.removeAll() @Suppress("DEPRECATION") responses = call.toFlowV3() responses.test { @@ -589,7 +589,7 @@ class FetchPolicyTest { /** * clear the cache and trigger the watcher again */ - store.clearAll() + store.removeAll() mockServer.enqueueString( buildJsonString { @@ -644,7 +644,7 @@ class FetchPolicyTest { assertTrue(response.isFromCache) // CacheOnly / miss - store.clearAll() + store.removeAll() response = apolloClient.query(query) .fetchPolicy(FetchPolicy.CacheOnly) .execute() @@ -660,7 +660,7 @@ class FetchPolicyTest { assertFalse(response.isFromCache) // CacheFirst / miss / miss - store.clearAll() + store.removeAll() mockServer.enqueueString("malformed") var responses = apolloClient.query(query) .fetchPolicy(FetchPolicy.CacheFirst) @@ -670,7 +670,7 @@ class FetchPolicyTest { assertFalse(responses[1].isFromCache) // NetworkFirst / miss / miss - store.clearAll() + store.removeAll() mockServer.enqueueString("malformed") responses = apolloClient.query(query) .fetchPolicy(FetchPolicy.NetworkFirst) diff --git a/tests/normalized-cache/src/commonTest/kotlin/ThreadTests.kt b/tests/normalized-cache/src/commonTest/kotlin/ThreadTests.kt index 684c1c88..f83d4f67 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/ThreadTests.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/ThreadTests.kt @@ -41,11 +41,11 @@ class ThreadTests { return delegate.merge(records, cacheHeaders, recordMerger) } - override fun clearAll() { + override fun removeAll() { check(currentThreadId() != mainThreadId) { "Cache access on main thread" } - return delegate.clearAll() + return delegate.removeAll() } override fun remove(cacheKey: CacheKey, cascade: Boolean): Boolean { diff --git a/tests/normalized-cache/src/commonTest/kotlin/WatcherTest.kt b/tests/normalized-cache/src/commonTest/kotlin/WatcherTest.kt index aa93c918..2985a932 100644 --- a/tests/normalized-cache/src/commonTest/kotlin/WatcherTest.kt +++ b/tests/normalized-cache/src/commonTest/kotlin/WatcherTest.kt @@ -657,7 +657,7 @@ class WatcherTest { assertEquals("R2-D2", awaitItem().data?.hero?.name) // Clear the cache - store.clearAll() + store.removeAll() store.publish(ApolloStore.ALL_KEYS) assertIs(awaitItem().exception) } diff --git a/tests/normalized-cache/src/concurrentTest/kotlin/MemoryCacheOnlyTest.kt b/tests/normalized-cache/src/concurrentTest/kotlin/MemoryCacheOnlyTest.kt index a7b10204..e54bed4d 100644 --- a/tests/normalized-cache/src/concurrentTest/kotlin/MemoryCacheOnlyTest.kt +++ b/tests/normalized-cache/src/concurrentTest/kotlin/MemoryCacheOnlyTest.kt @@ -23,7 +23,7 @@ import kotlin.test.assertIs class MemoryCacheOnlyTest { @Test fun memoryCacheOnlyDoesNotStoreInSqlCache() = runTest { - val store = ApolloStore(MemoryCacheFactory().chain(SqlNormalizedCacheFactory())).also { it.clearAll() } + val store = ApolloStore(MemoryCacheFactory().chain(SqlNormalizedCacheFactory())).also { it.removeAll() } val apolloClient = ApolloClient.Builder().networkTransport(QueueTestNetworkTransport()).store(store).build() val query = GetUserQuery() apolloClient.enqueueTestResponse(query, GetUserQuery.Data(GetUserQuery.User("John", "a@a.com"))) @@ -35,7 +35,7 @@ class MemoryCacheOnlyTest { @Test fun memoryCacheOnlyDoesNotReadFromSqlCache() = runTest { - val store = ApolloStore(MemoryCacheFactory().chain(SqlNormalizedCacheFactory())).also { it.clearAll() } + val store = ApolloStore(MemoryCacheFactory().chain(SqlNormalizedCacheFactory())).also { it.removeAll() } val query = GetUserQuery() store.writeOperation(query, GetUserQuery.Data(GetUserQuery.User("John", "a@a.com"))) diff --git a/tests/pagination/src/commonTest/kotlin/ConnectionPaginationTest.kt b/tests/pagination/src/commonTest/kotlin/ConnectionPaginationTest.kt index e42d466f..b728e753 100644 --- a/tests/pagination/src/commonTest/kotlin/ConnectionPaginationTest.kt +++ b/tests/pagination/src/commonTest/kotlin/ConnectionPaginationTest.kt @@ -44,7 +44,7 @@ class ConnectionPaginationTest { cacheResolver = FieldPolicyCacheResolver, recordMerger = ConnectionRecordMerger ) - apolloStore.clearAll() + apolloStore.removeAll() // First page val query1 = UsersQuery(first = Optional.Present(2)) @@ -369,7 +369,7 @@ class ConnectionPaginationTest { cacheResolver = FieldPolicyCacheResolver, recordMerger = ConnectionRecordMerger ) - apolloStore.clearAll() + apolloStore.removeAll() val query = UsersQuery(first = Optional.Present(2)) apolloStore.writeOperation( operation = query, diff --git a/tests/pagination/src/commonTest/kotlin/ConnectionProgrammaticPaginationTest.kt b/tests/pagination/src/commonTest/kotlin/ConnectionProgrammaticPaginationTest.kt index 65511788..ca19c63e 100644 --- a/tests/pagination/src/commonTest/kotlin/ConnectionProgrammaticPaginationTest.kt +++ b/tests/pagination/src/commonTest/kotlin/ConnectionProgrammaticPaginationTest.kt @@ -53,7 +53,7 @@ class ConnectionProgrammaticPaginationTest { connectionFields = connectionFields ), ) - apolloStore.clearAll() + apolloStore.removeAll() // First page val query1 = UsersQuery(first = Optional.Present(2)) diff --git a/tests/pagination/src/commonTest/kotlin/ConnectionWithNodesPaginationTest.kt b/tests/pagination/src/commonTest/kotlin/ConnectionWithNodesPaginationTest.kt index 43cc0e2c..56630a94 100644 --- a/tests/pagination/src/commonTest/kotlin/ConnectionWithNodesPaginationTest.kt +++ b/tests/pagination/src/commonTest/kotlin/ConnectionWithNodesPaginationTest.kt @@ -42,7 +42,7 @@ class ConnectionWithNodesPaginationTest { cacheResolver = FieldPolicyCacheResolver, recordMerger = ConnectionRecordMerger ) - apolloStore.clearAll() + apolloStore.removeAll() // First page val query1 = UsersQuery(first = Optional.Present(2)) diff --git a/tests/pagination/src/commonTest/kotlin/CursorBasedPaginationTest.kt b/tests/pagination/src/commonTest/kotlin/CursorBasedPaginationTest.kt index 95ce8023..20498f07 100644 --- a/tests/pagination/src/commonTest/kotlin/CursorBasedPaginationTest.kt +++ b/tests/pagination/src/commonTest/kotlin/CursorBasedPaginationTest.kt @@ -50,7 +50,7 @@ class CursorBasedPaginationTest { cacheResolver = FieldPolicyCacheResolver, recordMerger = ConnectionRecordMerger ) - apolloStore.clearAll() + apolloStore.removeAll() // First page val query1 = UsersQuery(first = Optional.Present(2)) diff --git a/tests/pagination/src/commonTest/kotlin/OffsetBasedWithArrayPaginationTest.kt b/tests/pagination/src/commonTest/kotlin/OffsetBasedWithArrayPaginationTest.kt index b5789422..86845d97 100644 --- a/tests/pagination/src/commonTest/kotlin/OffsetBasedWithArrayPaginationTest.kt +++ b/tests/pagination/src/commonTest/kotlin/OffsetBasedWithArrayPaginationTest.kt @@ -43,7 +43,7 @@ class OffsetBasedWithArrayPaginationTest { cacheResolver = FieldPolicyCacheResolver, recordMerger = FieldRecordMerger(OffsetPaginationFieldMerger()) ) - apolloStore.clearAll() + apolloStore.removeAll() // First page val query1 = UsersQuery(offset = Optional.Present(42), limit = Optional.Present(2)) diff --git a/tests/pagination/src/commonTest/kotlin/OffsetBasedWithPageAndInputPaginationTest.kt b/tests/pagination/src/commonTest/kotlin/OffsetBasedWithPageAndInputPaginationTest.kt index 1ad53c95..c7667120 100644 --- a/tests/pagination/src/commonTest/kotlin/OffsetBasedWithPageAndInputPaginationTest.kt +++ b/tests/pagination/src/commonTest/kotlin/OffsetBasedWithPageAndInputPaginationTest.kt @@ -51,7 +51,7 @@ class OffsetBasedWithPageAndInputPaginationTest { recordMerger = FieldRecordMerger(OffsetPaginationFieldMerger()), fieldKeyGenerator = UsersFieldKeyGenerator, ) - apolloStore.clearAll() + apolloStore.removeAll() // First page val query1 = UsersQuery(offset = Optional.Present(42), limit = Optional.Present(2)) diff --git a/tests/pagination/src/commonTest/kotlin/OffsetBasedWithPagePaginationTest.kt b/tests/pagination/src/commonTest/kotlin/OffsetBasedWithPagePaginationTest.kt index ed2bdfdc..b0e875bb 100644 --- a/tests/pagination/src/commonTest/kotlin/OffsetBasedWithPagePaginationTest.kt +++ b/tests/pagination/src/commonTest/kotlin/OffsetBasedWithPagePaginationTest.kt @@ -46,7 +46,7 @@ class OffsetBasedWithPagePaginationTest { cacheResolver = FieldPolicyCacheResolver, recordMerger = FieldRecordMerger(OffsetPaginationFieldMerger()) ) - apolloStore.clearAll() + apolloStore.removeAll() // First page val query1 = UsersQuery(offset = Optional.Present(42), limit = Optional.Present(2)) diff --git a/tests/store-errors/src/commonTest/kotlin/test/StoreErrorsTest.kt b/tests/store-errors/src/commonTest/kotlin/test/StoreErrorsTest.kt index 9fda53c7..dba6fc93 100644 --- a/tests/store-errors/src/commonTest/kotlin/test/StoreErrorsTest.kt +++ b/tests/store-errors/src/commonTest/kotlin/test/StoreErrorsTest.kt @@ -43,9 +43,9 @@ class StoreErrorsTest { private val memoryStore = ApolloStore(MemoryCacheFactory()) - private val sqlStore = ApolloStore(SqlNormalizedCacheFactory()).also { it.clearAll() } + private val sqlStore = ApolloStore(SqlNormalizedCacheFactory()).also { it.removeAll() } - private val memoryThenSqlStore = ApolloStore(MemoryCacheFactory().chain(SqlNormalizedCacheFactory())).also { it.clearAll() } + private val memoryThenSqlStore = ApolloStore(MemoryCacheFactory().chain(SqlNormalizedCacheFactory())).also { it.removeAll() } @Test fun simpleMemory() = runTest(before = { setUp() }, after = { tearDown() }) {