docs: change config snippets to use defineConfig (#7546)

This commit is contained in:
Shahed Nasser
2024-05-30 16:47:28 +03:00
committed by GitHub
parent ddfd757277
commit fe96bd39b1
51 changed files with 489 additions and 718 deletions
@@ -152,14 +152,20 @@ To use your Cache Module, add it to the `modules` object exported as part of the
For example:
```js title="medusa-config.js"
const modules = {
// other modules...
cacheService: {
resolve: "./dist/modules/my-cache/index.ts",
options: {
// any necessary options
ttl: 30,
const { Modules } = require("@medusajs/modules-sdk")
// ...
module.exports = defineConfig({
// ...
modules: {
[Modules.CACHE]: {
resolve: "./modules/my-cache",
options: {
// any options
ttl: 30,
},
},
},
}
}
})
```
@@ -16,6 +16,12 @@ For production, its recommended to use modules like [Redis Cache Module](../r
## Install the In-Memory Cache Module
<Note>
The In-Memory Cache Module is installed by default in your application.
</Note>
To install the In-Memory Cache Module, run the following command in the directory of your Medusa application:
```bash npm2yarn
@@ -29,18 +35,17 @@ const { Modules } = require("@medusajs/modules-sdk")
// ...
module.exports = {
module.exports = defineConfig({
// ...
modules: {
// ...
[Modules.CACHE]: {
resolve: "@medusajs/cache-inmemory",
options: {
// optional options
},
},
},
}
}
})
```
### In-Memory Cache Module Options
@@ -27,7 +27,7 @@ npm install @medusajs/cache-redis
Next, add the module into the `modules` property of the exported object in `medusa-config.js`:
export const highlights = [
["12", "redisUrl", "The Redis connection URL."]
["11", "redisUrl", "The Redis connection URL."]
]
```js title="medusa-config.js" highlights={highlights}
@@ -35,18 +35,17 @@ const { Modules } = require("@medusajs/modules-sdk")
// ...
module.exports = {
module.exports = defineConfig({
// ...
modules: {
// ...
[Modules.CACHE]: {
resolve: "@medusajs/cache-redis",
options: {
redisUrl: process.env.CACHE_REDIS_URL,
},
},
},
}
}
})
```
### Environment Variables