Files
medusa-store/www/apps/resources/app/infrastructure-modules/cache/redis/page.mdx
Shahed Nasser 76f9da5ef4 docs: Caching Module (#13701)
* standard docs for caching module + deprecated cache module

* added guides for creating + using, and overall changes from cache to caching

* fix details related to redis provider

* fix build errors

* fix build error

* fixes

* add guides to sidebar

* add sidebar util

* document query + index

* moved cache tag conventions

* fix build errors

* added migration guide

* added memcached guide

* fixes

* general fixes and updates

* updated reference

* document medusa cache

* small fix

* fixes

* remove cloud cache

* revert edit dates changes

* revert edit dates

* small update
2025-10-21 10:34:27 +03:00

174 lines
3.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { Table, Prerequisites } from "docs-ui"
export const metadata = {
title: `Redis Cache Module`,
}
# {metadata.title}
The Redis Cache Module uses Redis to cache data in your store. In production, it's recommended to use this module.
<Note title="Deprecation Notice">
The Redis Cache Module is deprecated starting from [Medusa v2.11.0](https://github.com/medusajs/medusa/releases/tag/v2.11.0). Use the [Redis Caching Module Provider](../../caching/providers/redis/page.mdx) instead.
</Note>
---
## Register the Redis Cache Module
<Prerequisites items={[
{
text: "Redis installed and Redis server running",
link: "https://redis.io/docs/getting-started/installation/"
}
]} />
Add the module into the `modules` property of the exported object in `medusa-config.ts`:
export const highlights = [
["11", "redisUrl", "The Redis connection URL."]
]
```ts title="medusa-config.ts" highlights={highlights}
module.exports = defineConfig({
// ...
modules: [
{
resolve: "@medusajs/medusa/cache-redis",
options: {
redisUrl: process.env.CACHE_REDIS_URL,
},
},
],
})
```
### Environment Variables
Make sure to add the following environment variables:
```bash
CACHE_REDIS_URL=<YOUR_REDIS_URL>
```
### Redis Cache Module Options
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Option</Table.HeaderCell>
<Table.HeaderCell>Description</Table.HeaderCell>
<Table.HeaderCell>Required</Table.HeaderCell>
<Table.HeaderCell>Default</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>
`redisUrl`
</Table.Cell>
<Table.Cell>
A string indicating the Redis connection URL.
</Table.Cell>
<Table.Cell>
Yes
</Table.Cell>
<Table.Cell>
\-
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`redisOptions`
</Table.Cell>
<Table.Cell>
An object of Redis options. Refer to the [Redis API Reference](https://redis.github.io/ioredis/index.html#RedisOptions) for details on accepted properties.
</Table.Cell>
<Table.Cell>
No
</Table.Cell>
<Table.Cell>
\-
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`ttl`
</Table.Cell>
<Table.Cell>
The number of seconds an item can live in the cache before its removed.
</Table.Cell>
<Table.Cell>
No
</Table.Cell>
<Table.Cell>
`30` seconds
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`namespace`
</Table.Cell>
<Table.Cell>
A string used to prefix all cached keys with `{namespace}:`.
</Table.Cell>
<Table.Cell>
No
</Table.Cell>
<Table.Cell>
`medusa`. So, all cached keys are prefixed with `medusa:`.
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
---
## Test the Module
To test the module, start the Medusa application:
```bash npm2yarn
npm run dev
```
You'll see the following message in the terminal's logs:
```bash noCopy noReport
Connection to Redis in module 'cache-redis' established
```