Skip to content

Commit

Permalink
docs: add cache base option example & description
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisHaftmann authored Dec 23, 2022
1 parent 4ed8efe commit ab81a39
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/content/1.guide/1.introduction/5.cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const cachedFn = cachedEventHandler(fn, options)
- `integrity`: A value that changing it, will invalidate all caches for function. By default will be computed from **function code**.
- `maxAge`: Maximum age that cache is valid in seconds. Default is `1` second.
- `swr`: Enable Stale-While-Revalidate behavior. Enabled by default.
- `base`: Name of the storage mointpoint to use for caching (`/cache` by default)


## Examples
Expand Down Expand Up @@ -54,3 +55,28 @@ export default defineNitroConfig({
}
})
```


**Example:** Set cache storage mountpoint for a group of routes (**🧪 Experimental!**)

```js
// nitro.config.ts
import { defineNitroConfig } from 'nitropack'

export default defineNitroConfig({
storage: {
'my-custom-storage': {
driver: 'redis',
url: 'redis://localhost:6379'
}
},
routeRules: {
'/blog/**': {
swr: true,
cache: {
base: '/my-custom-storage'
}
}
}
})
```

0 comments on commit ab81a39

Please sign in to comment.