Skip to content

Commit

Permalink
Fix use cache example line highlights
Browse files Browse the repository at this point in the history
Have not tested
  • Loading branch information
gaearon authored Oct 26, 2024
1 parent 5a0d603 commit 1015c08
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/02-app/02-api-reference/01-directives/use-cache.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ A `cacheTag` is used in combination with [`revalidateTag`](/docs/app/api-referen

In the below example the `getData` function uses the “weeks” cache profile, and defines a `cacheTag` on the functions cached output:

```tsx filename="app/actions.ts" highlight={4,5}
```tsx filename="app/actions.ts" highlight={8,9}
import {
unstable_cacheTag as cacheTag,
unstable_cacheLife as cacheLife,
Expand All @@ -286,7 +286,7 @@ export async function getData() {

You can then purge the cache on-demand using revalidateTag in another function, for examples, a [route handler](/docs/app/building-your-application/routing/route-handlers) or [Server Action](/docs/app/building-your-application/data-fetching/server-actions-and-mutations):

```tsx filename="app/submit.ts" highlight={4,5}
```tsx filename="app/submit.ts" highlight={6,7}
'use server'

import { revalidateTag } from 'next/cache'
Expand All @@ -311,7 +311,7 @@ This is recommended for applications that previously used the [`export const dyn

```tsx filename="app/layout.tsx"
"use cache"
import { unstable_cacheLife as cacheLife} from 'next/cache'
import { unstable_cacheLife as cacheLife } from 'next/cache'
cacheLife('minutes')

export default Layout({children}: {children: ReactNode}) {
Expand All @@ -323,7 +323,7 @@ And in your `page.tsx` file you can add the `use cache` directive to the top of

```tsx filename="app/page.tsx"
"use cache"
import { unstable_cacheLife as cacheLife} from 'next/cache'
import { unstable_cacheLife as cacheLife } from 'next/cache'
cacheLife('minutes')

async function Users() {
Expand All @@ -346,7 +346,7 @@ You can use `use cache` at the component level to cache any fetches or computati

The props are serialized and form part of the cache key. If you use the same component in multiple places in your application, the cache entry will be reused as long as the serialized props produce the same value in each instance.

```tsx filename="app/components/bookings.tsx" highlight={4,5}
```tsx filename="app/components/bookings.tsx" highlight={8,9}
import { unstable_cacheLife as cacheLife } from 'next/cache'

interface BookingsProps {
Expand Down

0 comments on commit 1015c08

Please sign in to comment.