In-Memory Cache Module

The In-Memory Cache Module uses a plain JavaScript Map object to store the cached data. This module is used by default in your Medusa application.

This module is helpful for development or when you’re testing out Medusa, but it’s not recommended to be used in production.

For production, it’s recommended to use modules like Redis Cache Module.


Register the In-Memory Cache Module#

NoteThe In-Memory Cache Module is registered by default in your application.

Add the module into the modules property of the exported object in medusa-config.ts:

medusa-config.ts
1import { Modules } from "@medusajs/framework/utils"2// ...3
4module.exports = defineConfig({5  // ...6  modules: [7    {8      resolve: "@medusajs/medusa/cache-inmemory",9      options: {10        // optional options11      },12    },13  ],14})

In-Memory Cache Module Options#

OptionDescriptionDefault

ttl

The number of seconds an item can live in the cache before it’s removed.

30 seconds

Was this page helpful?
Edit this page
Ask Anything
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break