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. Our Cloud offering automatically provisions a Redis instance and configures the Redis Cache Module for you. Learn more in the [Redis](!cloud!/redis) Cloud documentation. --- ## Register the Redis Cache Module 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} import { Modules } from "@medusajs/framework/utils" // ... 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= ``` ### Redis Cache Module Options Option Description Required Default `redisUrl` A string indicating the Redis connection URL. Yes \- `redisOptions` An object of Redis options. Refer to the [Redis API Reference](https://redis.github.io/ioredis/index.html#RedisOptions) for details on accepted properties. No \- `ttl` The number of seconds an item can live in the cache before it’s removed. No `30` seconds `namespace` A string used to prefix all cached keys with `{namespace}:`. No `medusa`. So, all cached keys are prefixed with `medusa:`.
--- ## 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 ```