You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/framework/angular/guides/caching.md
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ id: caching
3
3
title: Caching Examples
4
4
---
5
5
6
-
> Please thoroughly read the [Important Defaults](./important-defaults.md) before reading this guide
6
+
> Please thoroughly read the [Important Defaults](../important-defaults.md) before reading this guide
7
7
8
8
## Basic Example
9
9
@@ -23,11 +23,13 @@ Let's assume we are using the default `gcTime` of **5 minutes** and the default
23
23
- A second instance of `injectQuery(() => ({ queryKey: ['todos'], queryFn: fetchTodos })` initializes elsewhere.
24
24
- Since the cache already has data for the `['todos']` key from the first query, that data is immediately returned from the cache.
25
25
- The new instance triggers a new network request using its query function.
26
-
- Note that regardless of whether both `fetchTodos` query functions are identical or not, both queries' [`status`](../../reference/injectQuery.md) are updated (including `isFetching`, `isPending`, and other related values) because they have the same query key.
26
+
- Note that regardless of whether both `fetchTodos` query functions are identical or not, both queries' [`status`](../../reference/functions/injectquery.md) are updated (including `isFetching`, `isPending`, and other related values) because they have the same query key.
27
27
- When the request completes successfully, the cache's data under the `['todos']` key is updated with the new data, and both instances are updated with the new data.
28
28
- Both instances of the `injectQuery(() => ({ queryKey: ['todos'], queryFn: fetchTodos })` query are destroyed and no longer in use.
29
29
- Since there are no more active instances of this query, a garbage collection timeout is set using `gcTime` to delete and garbage collect the query (defaults to **5 minutes**).
30
30
- Before the cache timeout has completed, another instance of `injectQuery(() => ({ queryKey: ['todos'], queyFn: fetchTodos })` mounts. The query immediately returns the available cached data while the `fetchTodos` function is being run in the background. When it completes successfully, it will populate the cache with fresh data.
31
31
- The final instance of `injectQuery(() => ({ queryKey: ['todos'], queryFn: fetchTodos })` gets destroyed.
32
32
- No more instances of `injectQuery(() => ({ queryKey: ['todos'], queryFn: fetchTodos })` appear within **5 minutes**.
33
33
- The cached data under the `['todos']` key is deleted and garbage collected.
34
+
35
+
For more advanced use-cases, see [injectQuery](../../reference/functions/injectquery.md).
0 commit comments