@medusajs/cache-redis 2.22.0-snapshot-20261021091347 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/AGENTS.md +48 -0
  2. package/README.md +72 -16
  3. package/package.json +7 -3
package/AGENTS.md ADDED
@@ -0,0 +1,48 @@
1
+ # @medusajs/cache-redis
2
+
3
+ Redis implementation of the legacy Cache Module (`Modules.CACHE`, container key `"cache"`). Used by `defineConfig` on Medusa Cloud when `REDIS_URL` is set. Deprecated since v2.11.0 in favor of the Caching Module with the Redis Caching provider (`@medusajs/medusa/caching-redis`).
4
+
5
+ ## Using this package
6
+
7
+ ```ts
8
+ module.exports = defineConfig({
9
+ modules: [
10
+ {
11
+ resolve: "@medusajs/medusa/cache-redis",
12
+ options: {
13
+ redisUrl: process.env.CACHE_REDIS_URL,
14
+ },
15
+ },
16
+ ],
17
+ })
18
+ ```
19
+
20
+ - Options (`RedisCacheModuleOptions`, `src/types/index.ts`):
21
+ - `redisUrl` (required)
22
+ - `ttl`: seconds, default `30`
23
+ - `redisOptions`: ioredis `RedisOptions`, spread over `{ lazyConnect: true }`
24
+ - `namespace`: key prefix, default `"medusa"` (keys stored as `medusa:<key>`)
25
+ - Resolve: `container.resolve(Modules.CACHE)` (`ICacheService`): `get`, `set`, `invalidate`.
26
+ - No data models, events, links, or providers.
27
+ - Docs: https://docs.medusajs.com/resources/infrastructure-modules/cache/redis.md, https://docs.medusajs.com/resources/infrastructure-modules/caching/providers/redis.md
28
+
29
+ ## Architecture
30
+
31
+ - `src/loaders/index.ts`: creates the ioredis connection and registers it as `cacheRedisConnection` in the module container.
32
+ - `src/services/redis-cache.ts`: values are `JSON.stringify`'d and stored with `SET ... EX <ttl>`; `invalidate` walks `SCAN MATCH <namespace>:<key> COUNT 100` and `UNLINK`s matches in a pipeline.
33
+ - Disconnects in `__hooks.onApplicationShutdown`.
34
+ - `src/initialize/index.ts`: standalone bootstrap via `MedusaModule.bootstrap`.
35
+
36
+ ## Development
37
+
38
+ ```bash
39
+ yarn build
40
+ yarn test # src/services/__tests__/redis-cache.js (mocked client, no Redis needed)
41
+ ```
42
+
43
+ ## Gotchas
44
+
45
+ - Missing `redisUrl` throws at load time, but a failed connection is only logged (`logger.error`), so the app boots and cache calls fail later.
46
+ - `get` deletes the key (`UNLINK`) and returns `null` if the read or `JSON.parse` throws.
47
+ - `set(key, data, 0)` is a no-op.
48
+ - `invalidate` patterns use Redis glob syntax (`*`, `?`, `[...]`) and are prefixed with the namespace.
package/README.md CHANGED
@@ -1,27 +1,83 @@
1
- # Medusa Cache Redis
1
+ <p align="center">
2
+ <a href="https://www.medusajs.com">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/59018053/229103275-b5e482bb-4601-46e6-8142-244f531cebdb.svg">
5
+ <source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/59018053/229103726-e5b529a3-9b3f-4970-8a1f-c6af37f087bf.svg">
6
+ <img alt="Medusa logo" src="https://user-images.githubusercontent.com/59018053/229103726-e5b529a3-9b3f-4970-8a1f-c6af37f087bf.svg">
7
+ </picture>
8
+ </a>
9
+ </p>
10
+ <h1 align="center">
11
+ @medusajs/cache-redis
12
+ </h1>
2
13
 
3
- Use Redis as a Medusa cache store.
14
+ <h4 align="center">
15
+ <a href="https://docs.medusajs.com">Documentation</a> |
16
+ <a href="https://www.medusajs.com">Website</a>
17
+ </h4>
4
18
 
5
- ## Installation
19
+ <p align="center">
20
+ Building blocks for digital commerce
21
+ </p>
22
+ <p align="center">
23
+ <a href="https://github.com/medusajs/medusa/blob/develop/LICENSE">
24
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="Medusa is released under the MIT license." />
25
+ </a>
26
+ <a href="https://github.com/medusajs/medusa/blob/develop/CONTRIBUTING.md">
27
+ <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" alt="PRs welcome!" />
28
+ </a>
29
+ <a href="https://discord.gg/xpCwq3Kfn8">
30
+ <img src="https://img.shields.io/badge/chat-on%20discord-7289DA.svg" alt="Discord Chat" />
31
+ </a>
32
+ <a href="https://twitter.com/intent/follow?screen_name=medusajs">
33
+ <img src="https://img.shields.io/twitter/follow/medusajs.svg?label=Follow%20@medusajs" alt="Follow @medusajs" />
34
+ </a>
35
+ </p>
6
36
 
7
- ```
8
- yarn add @medusajs/cache-redis
9
- ```
37
+ Redis Cache Module for Medusa: stores cached data in Redis. **Deprecated since Medusa v2.11.0**: use the [Caching Module](../caching) with the [Redis Caching Module Provider](../providers/caching-redis) (`@medusajs/caching-redis`) instead. It ships with `@medusajs/medusa` and is registered from `@medusajs/medusa/cache-redis`.
10
38
 
11
- ## Options
39
+ ## At a glance
12
40
 
13
- ```
14
- {
15
- ttl?: number // Time to keep data in cache (in seconds)
41
+ | | |
42
+ | --- | --- |
43
+ | Package | `@medusajs/cache-redis` |
44
+ | Type | Infrastructure Module (deprecated) |
45
+ | Module key | `Modules.CACHE` (`"cache"`) |
46
+ | Registered by default | No (the In-Memory Cache Module is the default) |
47
+ | Import from | `@medusajs/medusa/cache-redis` |
16
48
 
17
- redisUrl?: string // Redis instance connection string
49
+ ## Installation
18
50
 
19
- redisOptions?: RedisOptions // Redis client options
51
+ No installation needed. The module ships with `@medusajs/medusa`, but you must register it in `medusa-config.ts`.
20
52
 
21
- namespace?: string // Prefix for event keys (the default is `medusa:`)
22
- }
53
+ ## Usage
54
+
55
+ ```ts title="medusa-config.ts"
56
+ import { defineConfig } from "@medusajs/framework/utils"
57
+
58
+ module.exports = defineConfig({
59
+ // ...
60
+ modules: [
61
+ {
62
+ resolve: "@medusajs/medusa/cache-redis",
63
+ options: {
64
+ redisUrl: process.env.CACHE_REDIS_URL,
65
+ },
66
+ },
67
+ ],
68
+ })
23
69
  ```
24
70
 
25
- ### Other caching modules
71
+ ## Configuration
72
+
73
+ | Option | Type | Description | Default |
74
+ | --- | --- | --- | --- |
75
+ | `redisUrl` | `string` | Redis connection URL. | - |
76
+ | `redisOptions` | `RedisOptions` (from `ioredis`) | Options passed to the Redis client. | - |
77
+ | `ttl` | `number` | Time to keep data in the cache, in seconds. | `30` |
78
+ | `namespace` | `string` | Prefix added to cache keys. | `"medusa"` |
79
+
80
+ ## Resources
26
81
 
27
- - [Medusa Cache In-Memory](../cache-inmemory/README.md)
82
+ - [Redis Cache Module](https://docs.medusajs.com/resources/infrastructure-modules/cache/redis)
83
+ - [Migrate from the Cache Module to the Caching Module](https://docs.medusajs.com/resources/infrastructure-modules/caching/migrate-cache)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/cache-redis",
3
- "version": "2.22.0-snapshot-20261021091347",
3
+ "version": "2.22.0",
4
4
  "description": "Redis Cache Module for Medusa",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -19,14 +19,18 @@
19
19
  },
20
20
  "files": [
21
21
  "dist",
22
+ "AGENTS.md",
22
23
  "!dist/**/__tests__",
23
24
  "!dist/**/__mocks__",
24
25
  "!dist/**/__fixtures__"
25
26
  ],
27
+ "llms": "https://docs.medusajs.com/llms.txt",
28
+ "llmsFull": "https://docs.medusajs.com/llms-full.txt",
29
+ "mcpServer": "https://docs.medusajs.com/mcp",
26
30
  "author": "Medusa",
27
31
  "license": "MIT",
28
32
  "devDependencies": {
29
- "@medusajs/framework": "2.22.0-snapshot-20261021091347"
33
+ "@medusajs/framework": "2.22.0"
30
34
  },
31
35
  "scripts": {
32
36
  "watch": "yarn run -T tsc --build --watch",
@@ -37,6 +41,6 @@
37
41
  "ioredis": "^5.4.1"
38
42
  },
39
43
  "peerDependencies": {
40
- "@medusajs/framework": "2.22.0-snapshot-20261021091347"
44
+ "@medusajs/framework": "2.22.0"
41
45
  }
42
46
  }