Files
medusa-store/docs/content/development/cache/overview.mdx
2023-04-03 13:50:59 +02:00

66 lines
2.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.
---
description: 'In this document, youll learn about Cache Modules in Medusa, how they work, and which modules Medusa provides.'
---
import DocCardList from '@theme/DocCardList';
import DocCard from '@theme/DocCard';
import Icons from '@theme/Icon';
# Cache
In this document, youll learn about Cache Modules in Medusa, how they work, and which modules Medusa provides.
## Overview
Cache is used in Medusa to store the results of computations such as price selection or various tax calculations. The caching layer in Medusa is implemented as a [module](../modules/overview.mdx). This allows you to replace the underlying database/cache store in your project.
Modules are packages that export a service. The main service exported from a cache module has to implement the `ICacheService` interface exported from the `@medusajs/types` package.
During the app startup, the modules loader will load the service into the [dependency injection container](../fundamentals/dependency-injection.md) to be available as `cacheService` to the rest of the commerce application.
---
## Available Modules
Medusa default starter project comes with the in-memory cache module (`@medusajs/cache-inmemory`). In-memory cache uses a plain JS Map object to store data, which is great for testing and development purposes.
For production environments, there is the Redis cache module package (`@medusajs/cache-redis`) that you can install.
<DocCardList colSize={6} items={[
{
type: 'link',
href: '/development/cache/modules/redis',
label: 'Redis Module',
customProps: {
icon: Icons['academic-cap-solid'],
description: 'Learn how to install and use the Redis Module'
}
},
{
type: 'link',
href: '/development/cache/modules/in-memory',
label: 'In-Memory Module',
customProps: {
icon: Icons['academic-cap-solid'],
description: 'Learn how to install and use the In-Memory Module'
}
},
]} />
---
## Custom Development
Developers can create custom cache modules to implement their custom cache logic. The module can be installed and used in any Medusa backend.
<DocCard item={{
type: 'link',
href: '/development/cache/create',
label: 'Create a Cache Module',
customProps: {
icon: Icons['academic-cap-solid'],
description: 'Learn how to create a cache module in Medusa.'
}
}}
/>