SwrCache

Implementation of the SwrClient interface.

Query internally manages two categories:

Query in the Active state does not disappear from memory unless one of the following conditions is met:

On the other hand, Query in the Inactive state gradually disappears from memory when one of the following conditions is met:

Mutation is managed similarly to Active state Query, but it is not explicitly deleted like removeQueries. Typically, since the result of Mutation execution is not reused, it does not cache after going inactive.

Parameters

policy

The policy for the SwrCache.

Inheritors

Constructors

Link copied to clipboard
constructor(coroutineScope: CoroutineScope)
constructor(policy: SwrCachePolicy)

Creates a new SwrCache instance.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The default mutation options.

Link copied to clipboard

The default query options.

Link copied to clipboard
open override val errorRelay: Flow<ErrorRecord>

Provides a unified feedback mechanism for all Query/Mutation errors that occur within the client.

Functions

Link copied to clipboard
open override fun gc(level: MemoryPressureLevel)

Releases data in memory based on the specified level.

Link copied to clipboard
open override fun <T, S> getInfiniteQuery(key: InfiniteQueryKey<T, S>, marker: Marker): InfiniteQueryRef<T, S>

Gets the InfiniteQueryRef by the specified InfiniteQueryKey.

Link copied to clipboard
open override fun <T, S> getInfiniteQueryData(id: InfiniteQueryId<T, S>): QueryChunks<T, S>?

Retrieves data of the InfiniteQueryKey associated with the id.

Link copied to clipboard
open override fun <T, S> getMutation(key: MutationKey<T, S>, marker: Marker): MutationRef<T, S>

Gets the MutationRef by the specified MutationKey.

Link copied to clipboard
open override fun <T> getQuery(key: QueryKey<T>, marker: Marker): QueryRef<T>

Gets the QueryRef by the specified QueryKey.

Link copied to clipboard
open override fun <T> getQueryData(id: QueryId<T>): T?

Retrieves data of the QueryKey associated with the id.

Link copied to clipboard
open override fun invalidateQueries(filter: InvalidateQueriesFilter)

Invalidates the queries by the specified InvalidateQueriesFilter.

Link copied to clipboard
open override fun <U : UniqueId> invalidateQueriesBy(vararg ids: U)

Invalidates the queries by the specified UniqueId.

Link copied to clipboard
open override fun onMount(id: String)

Executes initialization procedures based on events.

Link copied to clipboard
open override fun onUnmount(id: String)

Executes cleanup procedures based on events.

Link copied to clipboard
open override fun perform(sideEffects: QueryEffect): Job

Executes side effects for queries.

Link copied to clipboard
open override fun <T, S> prefetchInfiniteQuery(key: InfiniteQueryKey<T, S>, marker: Marker): Job

Prefetches the infinite query by the specified InfiniteQueryKey.

Link copied to clipboard
open override fun <T> prefetchQuery(key: QueryKey<T>, marker: Marker): Job

Prefetches the query by the specified QueryKey.

Link copied to clipboard
open override fun purgeAll()

Removes all queries and mutations from the in-memory stored data.

Link copied to clipboard
open override fun removeQueries(filter: RemoveQueriesFilter)

Removes the queries by the specified RemoveQueriesFilter.

Link copied to clipboard
open override fun <U : UniqueId> removeQueriesBy(vararg ids: U)

Removes the queries by the specified UniqueId.

Link copied to clipboard
open override fun resumeQueries(filter: ResumeQueriesFilter)

Resumes the queries by the specified ResumeQueriesFilter.

Link copied to clipboard
open override fun <U : UniqueId> resumeQueriesBy(vararg ids: U)

Resumes the queries by the specified UniqueId.

Link copied to clipboard
open override fun <T, S> updateInfiniteQueryData(id: InfiniteQueryId<T, S>, edit: QueryChunks<T, S>.() -> QueryChunks<T, S>)

Updates the data of the InfiniteQueryKey associated with the id.

Link copied to clipboard
open override fun <T> updateQueryData(id: QueryId<T>, edit: T.() -> T)

Updates the data of the QueryKey associated with the id.