@medusajs/caching-redis 2.10.4-snapshot-20250927182917

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.
@@ -0,0 +1,3 @@
1
+ declare const _default: import("@medusajs/types").ModuleProviderExports;
2
+ export default _default;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAQA,wBAGE"}
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("@medusajs/framework/utils");
7
+ const connection_1 = __importDefault(require("./loaders/connection"));
8
+ const hash_1 = __importDefault(require("./loaders/hash"));
9
+ const redis_cache_1 = require("./services/redis-cache");
10
+ const services = [redis_cache_1.RedisCachingProvider];
11
+ const loaders = [connection_1.default, hash_1.default];
12
+ exports.default = (0, utils_1.ModuleProvider)(utils_1.Modules.CACHING, {
13
+ services,
14
+ loaders,
15
+ });
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,qDAAmE;AACnE,sEAA6C;AAC7C,0DAAiC;AACjC,wDAA6D;AAE7D,MAAM,QAAQ,GAAG,CAAC,kCAAoB,CAAC,CAAA;AACvC,MAAM,OAAO,GAAG,CAAC,oBAAU,EAAE,cAAI,CAAC,CAAA;AAElC,kBAAe,IAAA,sBAAc,EAAC,eAAO,CAAC,OAAO,EAAE;IAC7C,QAAQ;IACR,OAAO;CACR,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { InternalModuleDeclaration, LoaderOptions, ModulesSdkTypes } from "@medusajs/framework/types";
2
+ declare const _default: ({ container, logger, options, }: LoaderOptions<(ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions) & {
3
+ logger?: any;
4
+ }>, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>;
5
+ export default _default;
6
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/loaders/connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,aAAa,EACb,eAAe,EAChB,MAAM,2BAA2B,CAAA;0DAS7B,aAAa,CACd,CACI,eAAe,CAAC,8BAA8B,GAC9C,eAAe,CAAC,6CAA6C,CAChE,GAAG;IAAE,MAAM,CAAC,EAAE,GAAG,CAAA;CAAE,CACrB,sBACmB,yBAAyB,KAC5C,OAAO,CAAC,IAAI,CAAC;AAZhB,wBAyDC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const ioredis_1 = __importDefault(require("ioredis"));
7
+ exports.default = async ({ container, logger, options, }, moduleDeclaration) => {
8
+ const logger_ = logger || console;
9
+ const moduleOptions = (options ??
10
+ moduleDeclaration?.options ??
11
+ {});
12
+ if (!moduleOptions.redisUrl) {
13
+ throw new Error("[caching-redis] redisUrl is required");
14
+ }
15
+ let redisClient;
16
+ try {
17
+ redisClient = new ioredis_1.default(moduleOptions.redisUrl, {
18
+ connectTimeout: 10000,
19
+ lazyConnect: true,
20
+ retryDelayOnFailover: 100,
21
+ connectionName: "medusa-cache-redis",
22
+ ...moduleOptions,
23
+ });
24
+ // Test connection
25
+ await redisClient.ping();
26
+ logger_.info("Redis cache connection established successfully");
27
+ }
28
+ catch (error) {
29
+ logger_.error(`Failed to connect to Redis cache: ${error.message}`);
30
+ redisClient = new ioredis_1.default(moduleOptions.redisUrl, {
31
+ connectTimeout: 10000,
32
+ lazyConnect: true,
33
+ retryDelayOnFailover: 100,
34
+ ...moduleOptions,
35
+ });
36
+ }
37
+ container.register({
38
+ redisClient: {
39
+ resolve: () => redisClient,
40
+ },
41
+ prefix: {
42
+ resolve: () => moduleOptions.prefix ?? "mc:",
43
+ },
44
+ });
45
+ };
46
+ //# sourceMappingURL=connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/loaders/connection.ts"],"names":[],"mappings":";;;;;AAMA,sDAA2B;AAE3B,kBAAe,KAAK,EAClB,EACE,SAAS,EACT,MAAM,EACN,OAAO,GAMR,EACD,iBAA6C,EAC9B,EAAE;IACjB,MAAM,OAAO,GAAG,MAAM,IAAI,OAAO,CAAA;IAEjC,MAAM,aAAa,GAAG,CAAC,OAAO;QAC5B,iBAAiB,EAAE,OAAO;QAC1B,EAAE,CAEH,CAAA;IAED,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;IACzD,CAAC;IAED,IAAI,WAAkB,CAAA;IAEtB,IAAI,CAAC;QACH,WAAW,GAAG,IAAI,iBAAK,CAAC,aAAa,CAAC,QAAS,EAAE;YAC/C,cAAc,EAAE,KAAK;YACrB,WAAW,EAAE,IAAI;YACjB,oBAAoB,EAAE,GAAG;YACzB,cAAc,EAAE,oBAAoB;YACpC,GAAG,aAAa;SACjB,CAAC,CAAA;QAEF,kBAAkB;QAClB,MAAM,WAAW,CAAC,IAAI,EAAE,CAAA;QACxB,OAAO,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAA;IACjE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,qCAAqC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;QACnE,WAAW,GAAG,IAAI,iBAAK,CAAC,aAAa,CAAC,QAAS,EAAE;YAC/C,cAAc,EAAE,KAAK;YACrB,WAAW,EAAE,IAAI;YACjB,oBAAoB,EAAE,GAAG;YACzB,GAAG,aAAa;SACjB,CAAC,CAAA;IACJ,CAAC;IAED,SAAS,CAAC,QAAQ,CAAC;QACjB,WAAW,EAAE;YACX,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW;SAC3B;QACD,MAAM,EAAE;YACN,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,IAAI,KAAK;SAC7C;KACF,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ declare const _default: ({ container }: {
2
+ container: any;
3
+ }) => Promise<void>;
4
+ export default _default;
5
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/loaders/hash.ts"],"names":[],"mappings":";;;AAEA,wBAKC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const awilix_1 = require("awilix");
4
+ exports.default = async ({ container }) => {
5
+ const xxhashhWasm = await import("xxhash-wasm");
6
+ const { h32ToString } = await xxhashhWasm.default();
7
+ container.register("hasher", (0, awilix_1.asValue)(h32ToString));
8
+ };
9
+ //# sourceMappingURL=hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/loaders/hash.ts"],"names":[],"mappings":";;AAAA,mCAAgC;AAEhC,kBAAe,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;IACrC,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAA;IAC/C,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,CAAA;IAEnD,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAA,gBAAO,EAAC,WAAW,CAAC,CAAC,CAAA;AACpD,CAAC,CAAA"}
@@ -0,0 +1,38 @@
1
+ import { RedisCacheModuleOptions } from "../types";
2
+ import { Redis } from "ioredis";
3
+ export declare class RedisCachingProvider {
4
+ #private;
5
+ static identifier: string;
6
+ protected redisClient: Redis;
7
+ protected keyNamePrefix: string;
8
+ protected defaultTTL: number;
9
+ protected compressionThreshold: number;
10
+ protected hasher: (key: string) => string;
11
+ constructor({ redisClient, prefix, hasher, }: {
12
+ redisClient: Redis;
13
+ prefix: string;
14
+ hasher: (key: string) => string;
15
+ }, options?: RedisCacheModuleOptions);
16
+ get({ key, tags }: {
17
+ key?: string;
18
+ tags?: string[];
19
+ }): Promise<any>;
20
+ set({ key, data, ttl, tags, options, }: {
21
+ key: string;
22
+ data: object;
23
+ ttl?: number;
24
+ tags?: string[];
25
+ options?: {
26
+ autoInvalidate?: boolean;
27
+ };
28
+ }): Promise<void>;
29
+ clear({ key, tags, options, }: {
30
+ key?: string;
31
+ tags?: string[];
32
+ options?: {
33
+ autoInvalidate?: boolean;
34
+ };
35
+ }): Promise<void>;
36
+ flush(): Promise<void>;
37
+ }
38
+ //# sourceMappingURL=redis-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis-cache.d.ts","sourceRoot":"","sources":["../../src/services/redis-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAA;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAG/B,qBAAa,oBAAoB;;IAC/B,MAAM,CAAC,UAAU,SAAgB;IAEjC,SAAS,CAAC,WAAW,EAAE,KAAK,CAAA;IAC5B,SAAS,CAAC,aAAa,EAAE,MAAM,CAAA;IAC/B,SAAS,CAAC,UAAU,EAAE,MAAM,CAAA;IAC5B,SAAS,CAAC,oBAAoB,EAAE,MAAM,CAAA;IACtC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;gBAGvC,EACE,WAAW,EACX,MAAM,EACN,MAAM,GACP,EAAE;QAAE,WAAW,EAAE,KAAK,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;KAAE,EAC1E,OAAO,CAAC,EAAE,uBAAuB;IA4D7B,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IA+DnE,GAAG,CAAC,EACR,GAAG,EACH,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,OAAO,GACR,EAAE;QACD,GAAG,EAAE,MAAM,CAAA;QACX,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;QACf,OAAO,CAAC,EAAE;YACR,cAAc,CAAC,EAAE,OAAO,CAAA;SACzB,CAAA;KACF,GAAG,OAAO,CAAC,IAAI,CAAC;IAmDX,KAAK,CAAC,EACV,GAAG,EACH,IAAI,EACJ,OAAO,GACR,EAAE;QACD,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;QACf,OAAO,CAAC,EAAE;YACR,cAAc,CAAC,EAAE,OAAO,CAAA;SACzB,CAAA;KACF,GAAG,OAAO,CAAC,IAAI,CAAC;IA2OX,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAsB7B"}
@@ -0,0 +1,364 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _RedisCachingProvider_instances, _RedisCachingProvider_getKeyName, _RedisCachingProvider_getTagKey, _RedisCachingProvider_getTagsKey, _RedisCachingProvider_compressData, _RedisCachingProvider_decompressData;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.RedisCachingProvider = void 0;
10
+ const lz4_wasm_nodejs_1 = require("lz4-wasm-nodejs");
11
+ class RedisCachingProvider {
12
+ constructor({ redisClient, prefix, hasher, }, options) {
13
+ _RedisCachingProvider_instances.add(this);
14
+ this.redisClient = redisClient;
15
+ this.keyNamePrefix = prefix;
16
+ this.defaultTTL = options?.ttl ?? 3600; // 1 hour default
17
+ this.compressionThreshold = options?.compressionThreshold ?? 1024; // 1KB default
18
+ this.hasher = hasher;
19
+ }
20
+ async get({ key, tags }) {
21
+ if (key) {
22
+ const keyName = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_getKeyName).call(this, key);
23
+ const data = await this.redisClient.hget(keyName, "data");
24
+ if (!data) {
25
+ return null;
26
+ }
27
+ const finalData = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_decompressData).call(this, data);
28
+ return JSON.parse(finalData);
29
+ }
30
+ if (tags?.length) {
31
+ // Get all keys associated with the tags
32
+ const pipeline = this.redisClient.pipeline();
33
+ tags.forEach((tag) => {
34
+ const tagKey = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_getTagKey).call(this, tag);
35
+ pipeline.smembers(tagKey);
36
+ });
37
+ const tagResults = await pipeline.exec();
38
+ const allKeys = new Set();
39
+ tagResults?.forEach((result, index) => {
40
+ if (result && result[1]) {
41
+ ;
42
+ result[1].forEach((key) => allKeys.add(key));
43
+ }
44
+ });
45
+ if (allKeys.size === 0) {
46
+ return [];
47
+ }
48
+ // Get all hash data for the keys
49
+ const valuePipeline = this.redisClient.pipeline();
50
+ Array.from(allKeys).forEach((key) => {
51
+ valuePipeline.hget(key, "data");
52
+ });
53
+ const valueResults = await valuePipeline.exec();
54
+ const results = [];
55
+ valueResults?.forEach((result, index) => {
56
+ if (result && result[1]) {
57
+ const data = result[1];
58
+ const finalData = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_decompressData).call(this, data);
59
+ try {
60
+ results.push(JSON.parse(finalData));
61
+ }
62
+ catch (e) {
63
+ // If JSON parsing fails, skip this entry (corrupted data)
64
+ console.warn(`Skipping corrupted cache entry: ${e.message}`);
65
+ }
66
+ }
67
+ });
68
+ return results;
69
+ }
70
+ return null;
71
+ }
72
+ async set({ key, data, ttl, tags, options, }) {
73
+ const keyName = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_getKeyName).call(this, key);
74
+ const serializedData = JSON.stringify(data);
75
+ const effectiveTTL = ttl ?? this.defaultTTL;
76
+ const finalData = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_compressData).call(this, serializedData);
77
+ const hashData = {
78
+ data: finalData,
79
+ };
80
+ if (options && Object.keys(options).length) {
81
+ hashData.options = JSON.stringify(options);
82
+ }
83
+ await this.redisClient.hset(keyName, hashData);
84
+ if (effectiveTTL) {
85
+ await this.redisClient.expire(keyName, effectiveTTL);
86
+ }
87
+ // Store tags in a separate key for inverted index lookup
88
+ if (tags && tags.length) {
89
+ const tagsKey = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_getTagsKey).call(this, key);
90
+ const tagsJson = JSON.stringify(tags);
91
+ const finalTagsData = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_compressData).call(this, tagsJson);
92
+ if (effectiveTTL) {
93
+ await this.redisClient.setex(tagsKey, effectiveTTL + 60, finalTagsData); // +1 minute buffer
94
+ }
95
+ else {
96
+ await this.redisClient.set(tagsKey, finalTagsData);
97
+ }
98
+ }
99
+ // Handle tags if provided
100
+ if (tags && tags.length) {
101
+ const pipeline = this.redisClient.pipeline();
102
+ tags.forEach((tag) => {
103
+ const tagKey = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_getTagKey).call(this, tag);
104
+ pipeline.sadd(tagKey, keyName);
105
+ // Set TTL for tag keys too (slightly longer than cache TTL)
106
+ if (effectiveTTL) {
107
+ pipeline.expire(tagKey, effectiveTTL + 60); // +1 minute buffer
108
+ }
109
+ });
110
+ await pipeline.exec();
111
+ }
112
+ }
113
+ async clear({ key, tags, options, }) {
114
+ if (key) {
115
+ const keyName = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_getKeyName).call(this, key);
116
+ // Get tags for this key to clean up tag sets
117
+ const tagsKey = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_getTagsKey).call(this, key);
118
+ const tagsData = await this.redisClient.get(tagsKey);
119
+ if (tagsData) {
120
+ try {
121
+ console.log("tagsData", tagsData);
122
+ const finalTagsData = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_decompressData).call(this, tagsData);
123
+ const entryTags = JSON.parse(finalTagsData);
124
+ // Remove this key from all its tag sets
125
+ if (entryTags.length) {
126
+ const tagCleanupPipeline = this.redisClient.pipeline();
127
+ entryTags.forEach((tag) => {
128
+ const tagKey = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_getTagKey).call(this, tag);
129
+ tagCleanupPipeline.srem(tagKey, keyName);
130
+ });
131
+ // Also delete the tags key
132
+ tagCleanupPipeline.unlink(tagsKey);
133
+ await tagCleanupPipeline.exec();
134
+ }
135
+ }
136
+ catch (e) {
137
+ throw new Error(`Failed to clear tags for key ${keyName}: ${e}`);
138
+ }
139
+ }
140
+ await this.redisClient.unlink(keyName);
141
+ return;
142
+ }
143
+ if (tags && tags.length) {
144
+ // Handle wildcard tag to clear all cache data
145
+ if (tags.includes("*")) {
146
+ await this.flush();
147
+ return;
148
+ }
149
+ // Get all keys associated with the tags
150
+ const pipeline = this.redisClient.pipeline();
151
+ tags.forEach((tag) => {
152
+ const tagKey = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_getTagKey).call(this, tag);
153
+ pipeline.smembers(tagKey);
154
+ });
155
+ const tagResults = await pipeline.exec();
156
+ const allKeys = new Set();
157
+ tagResults?.forEach((result, index) => {
158
+ if (result && result[1]) {
159
+ ;
160
+ result[1].forEach((key) => allKeys.add(key));
161
+ }
162
+ });
163
+ if (allKeys.size) {
164
+ // If no options provided (user explicit call), clear everything
165
+ if (!options) {
166
+ const deletePipeline = this.redisClient.pipeline();
167
+ // Delete main keys and options
168
+ Array.from(allKeys).forEach((key) => {
169
+ deletePipeline.unlink(key);
170
+ });
171
+ // Clean up tag references for each key
172
+ const tagDataPromises = Array.from(allKeys).map(async (key) => {
173
+ const keyWithoutPrefix = key.replace(this.keyNamePrefix, "");
174
+ const tagsKey = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_getTagsKey).call(this, keyWithoutPrefix);
175
+ const tagsData = await this.redisClient.get(tagsKey);
176
+ return { key, tagsKey, tagsData };
177
+ });
178
+ const tagResults = await Promise.all(tagDataPromises);
179
+ // Build single pipeline for all tag cleanup operations
180
+ const tagCleanupPipeline = this.redisClient.pipeline();
181
+ tagResults.forEach(({ key, tagsKey, tagsData }) => {
182
+ if (tagsData) {
183
+ try {
184
+ const finalTagsData = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_decompressData).call(this, tagsData);
185
+ const entryTags = JSON.parse(finalTagsData);
186
+ if (entryTags.length) {
187
+ entryTags.forEach((tag) => {
188
+ const tagKey = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_getTagKey).call(this, tag);
189
+ tagCleanupPipeline.srem(tagKey, key);
190
+ });
191
+ tagCleanupPipeline.unlink(tagsKey);
192
+ }
193
+ }
194
+ catch (e) {
195
+ throw new Error(`Failed to clear tags for key ${key}: ${e}`);
196
+ }
197
+ }
198
+ });
199
+ await tagCleanupPipeline.exec();
200
+ await deletePipeline.exec();
201
+ // Clean up empty tag sets
202
+ const allTagKeys = await this.redisClient.keys(`${this.keyNamePrefix}tag:*`);
203
+ if (allTagKeys.length) {
204
+ const cardinalityPipeline = this.redisClient.pipeline();
205
+ allTagKeys.forEach((tagKey) => {
206
+ cardinalityPipeline.scard(tagKey);
207
+ });
208
+ const cardinalityResults = await cardinalityPipeline.exec();
209
+ // Delete empty tag keys
210
+ const emptyTagPipeline = this.redisClient.pipeline();
211
+ cardinalityResults?.forEach((result, index) => {
212
+ if (result && result[1] === 0) {
213
+ emptyTagPipeline.unlink(allTagKeys[index]);
214
+ }
215
+ });
216
+ await emptyTagPipeline.exec();
217
+ }
218
+ return;
219
+ }
220
+ // If autoInvalidate is true (strategy call), only clear entries with autoInvalidate=true (default)
221
+ if (options.autoInvalidate === true) {
222
+ const optionsPipeline = this.redisClient.pipeline();
223
+ Array.from(allKeys).forEach((key) => {
224
+ optionsPipeline.hget(key, "options");
225
+ });
226
+ const optionsResults = await optionsPipeline.exec();
227
+ const keysToDelete = [];
228
+ Array.from(allKeys).forEach((key, index) => {
229
+ const optionsResult = optionsResults?.[index];
230
+ if (optionsResult && optionsResult[1]) {
231
+ try {
232
+ const entryOptions = JSON.parse(optionsResult[1]);
233
+ // Delete if entry has autoInvalidate=true or no setting (default true)
234
+ const shouldAutoInvalidate = entryOptions.autoInvalidate ?? true;
235
+ if (shouldAutoInvalidate) {
236
+ keysToDelete.push(key);
237
+ }
238
+ }
239
+ catch (e) {
240
+ throw new Error(`Failed to clear tags for key ${key}: ${e}`);
241
+ // If can't parse options, assume it's safe to delete (default true)
242
+ keysToDelete.push(key);
243
+ }
244
+ }
245
+ else {
246
+ // No options stored, default to true
247
+ keysToDelete.push(key);
248
+ }
249
+ });
250
+ if (keysToDelete.length) {
251
+ const deletePipeline = this.redisClient.pipeline();
252
+ keysToDelete.forEach((key) => {
253
+ deletePipeline.unlink(key);
254
+ });
255
+ // Clean up tag references for each key to delete
256
+ const tagDataPromises = keysToDelete.map(async (key) => {
257
+ const keyWithoutPrefix = key.replace(this.keyNamePrefix, "");
258
+ const tagsKey = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_getTagsKey).call(this, keyWithoutPrefix);
259
+ const tagsData = await this.redisClient.get(tagsKey);
260
+ return { key, tagsKey, tagsData };
261
+ });
262
+ const tagResults = await Promise.all(tagDataPromises);
263
+ const tagCleanupPipeline = this.redisClient.pipeline();
264
+ tagResults.forEach(({ key, tagsKey, tagsData }) => {
265
+ if (tagsData) {
266
+ try {
267
+ const finalTagsData = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_decompressData).call(this, tagsData);
268
+ const entryTags = JSON.parse(finalTagsData);
269
+ if (entryTags.length) {
270
+ entryTags.forEach((tag) => {
271
+ const tagKey = __classPrivateFieldGet(this, _RedisCachingProvider_instances, "m", _RedisCachingProvider_getTagKey).call(this, tag);
272
+ tagCleanupPipeline.srem(tagKey, key);
273
+ });
274
+ tagCleanupPipeline.unlink(tagsKey);
275
+ }
276
+ }
277
+ catch (e) {
278
+ // noop
279
+ }
280
+ }
281
+ });
282
+ await tagCleanupPipeline.exec();
283
+ await deletePipeline.exec();
284
+ const allTagKeys = await this.redisClient.keys(`${this.keyNamePrefix}tag:*`);
285
+ if (allTagKeys.length) {
286
+ const cleanupPipeline = this.redisClient.pipeline();
287
+ allTagKeys.forEach((tagKey) => {
288
+ cleanupPipeline.scard(tagKey);
289
+ });
290
+ const cardinalityResults = await cleanupPipeline.exec();
291
+ // Delete tag keys that are empty
292
+ const emptyTagDeletePipeline = this.redisClient.pipeline();
293
+ cardinalityResults?.forEach((result, index) => {
294
+ if (result && result[1] === 0) {
295
+ emptyTagDeletePipeline.unlink(allTagKeys[index]);
296
+ }
297
+ });
298
+ await emptyTagDeletePipeline.exec();
299
+ }
300
+ return;
301
+ }
302
+ }
303
+ }
304
+ }
305
+ }
306
+ async flush() {
307
+ // Use SCAN to find ALL keys with our prefix and delete them
308
+ // This includes main cache keys, tag keys (tag:*), and tags keys (tags:*)
309
+ const pattern = `${this.keyNamePrefix}*`;
310
+ let cursor = "0";
311
+ do {
312
+ const result = await this.redisClient.scan(cursor, "MATCH", pattern, "COUNT", 1000);
313
+ cursor = result[0];
314
+ const keys = result[1];
315
+ if (keys.length) {
316
+ await this.redisClient.unlink(...keys);
317
+ }
318
+ } while (cursor !== "0");
319
+ }
320
+ }
321
+ exports.RedisCachingProvider = RedisCachingProvider;
322
+ _RedisCachingProvider_instances = new WeakSet(), _RedisCachingProvider_getKeyName = function _RedisCachingProvider_getKeyName(key) {
323
+ return `${this.keyNamePrefix}${key}`;
324
+ }, _RedisCachingProvider_getTagKey = function _RedisCachingProvider_getTagKey(tag) {
325
+ return `${this.keyNamePrefix}tag:${this.hasher(tag)}`;
326
+ }, _RedisCachingProvider_getTagsKey = function _RedisCachingProvider_getTagsKey(key) {
327
+ return `${this.keyNamePrefix}tags:${key}`;
328
+ }, _RedisCachingProvider_compressData = function _RedisCachingProvider_compressData(data) {
329
+ if (data.length <= this.compressionThreshold) {
330
+ return `0:${data}`;
331
+ }
332
+ try {
333
+ const inputBuffer = new Uint8Array(Buffer.from(data, "utf8"));
334
+ const compressed = (0, lz4_wasm_nodejs_1.compress)(inputBuffer);
335
+ if (compressed.length < data.length) {
336
+ const compressedData = Buffer.from(compressed).toString("base64");
337
+ return `1:${compressedData}`;
338
+ }
339
+ else {
340
+ return `0:${data}`;
341
+ }
342
+ }
343
+ catch (error) {
344
+ return `0:${data}`;
345
+ }
346
+ }, _RedisCachingProvider_decompressData = function _RedisCachingProvider_decompressData(data) {
347
+ if (data.charAt(0) === "0") {
348
+ return data.substring(2);
349
+ }
350
+ if (data.charAt(0) === "1") {
351
+ const content = data.substring(2);
352
+ try {
353
+ const compressedBuffer = Buffer.from(content, "base64");
354
+ const decompressed = (0, lz4_wasm_nodejs_1.decompress)(new Uint8Array(compressedBuffer));
355
+ return Buffer.from(decompressed).toString("utf8");
356
+ }
357
+ catch (error) {
358
+ return content;
359
+ }
360
+ }
361
+ return data;
362
+ };
363
+ RedisCachingProvider.identifier = "cache-redis";
364
+ //# sourceMappingURL=redis-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis-cache.js","sourceRoot":"","sources":["../../src/services/redis-cache.ts"],"names":[],"mappings":";;;;;;;;;AAEA,qDAAsD;AAEtD,MAAa,oBAAoB;IAS/B,YACE,EACE,WAAW,EACX,MAAM,EACN,MAAM,GACkE,EAC1E,OAAiC;;QAEjC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,aAAa,GAAG,MAAM,CAAA;QAC3B,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,GAAG,IAAI,IAAI,CAAA,CAAC,iBAAiB;QACxD,IAAI,CAAC,oBAAoB,GAAG,OAAO,EAAE,oBAAoB,IAAI,IAAI,CAAA,CAAC,cAAc;QAChF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAqDD,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,EAAqC;QACxD,IAAI,GAAG,EAAE,CAAC;YACR,MAAM,OAAO,GAAG,uBAAA,IAAI,yEAAY,MAAhB,IAAI,EAAa,GAAG,CAAC,CAAA;YACrC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;YACzD,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,OAAO,IAAI,CAAA;YACb,CAAC;YAED,MAAM,SAAS,GAAG,uBAAA,IAAI,6EAAgB,MAApB,IAAI,EAAiB,IAAI,CAAC,CAAA;YAC5C,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QAC9B,CAAC;QAED,IAAI,IAAI,EAAE,MAAM,EAAE,CAAC;YACjB,wCAAwC;YACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EA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/loaders/connection.ts","../src/loaders/hash.ts","../src/services/redis-cache.ts","../src/types/index.ts"],"version":"5.6.2"}
@@ -0,0 +1,27 @@
1
+ export interface RedisCacheModuleOptions {
2
+ /**
3
+ * TTL in milliseconds
4
+ */
5
+ ttl?: number;
6
+ /**
7
+ * Connection timeout in milliseconds
8
+ */
9
+ connectTimeout?: number;
10
+ /**
11
+ * Lazyload connections
12
+ */
13
+ lazyConnect?: boolean;
14
+ /**
15
+ * Connection retries
16
+ */
17
+ retryDelayOnFailover?: number;
18
+ /**
19
+ * Key prefix for all cache keys
20
+ */
21
+ prefix?: string;
22
+ /**
23
+ * Minimum size in bytes to compress data (default: 1024)
24
+ */
25
+ compressionThreshold?: number;
26
+ }
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAC9B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@medusajs/caching-redis",
3
+ "version": "2.10.4-snapshot-20250927182917",
4
+ "description": "Redis Caching for Medusa",
5
+ "main": "dist/index.js",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/medusajs/medusa",
9
+ "directory": "packages/modules/providers/caching-redis"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "!dist/**/__tests__",
14
+ "!dist/**/__mocks__",
15
+ "!dist/**/__fixtures__"
16
+ ],
17
+ "engines": {
18
+ "node": ">=20"
19
+ },
20
+ "author": "Medusa",
21
+ "license": "MIT",
22
+ "devDependencies": {
23
+ "@medusajs/framework": "2.10.4-snapshot-20250927182917",
24
+ "@swc/core": "^1.7.28",
25
+ "@swc/jest": "^0.2.36",
26
+ "jest": "^29.7.0",
27
+ "rimraf": "^5.0.1",
28
+ "typescript": "^5.6.2"
29
+ },
30
+ "peerDependencies": {
31
+ "@medusajs/framework": "2.10.4-snapshot-20250927182917"
32
+ },
33
+ "dependencies": {
34
+ "ioredis": "^5.4.1",
35
+ "lz4-wasm-nodejs": "^0.9.2",
36
+ "xxhash-wasm": "^1.1.0"
37
+ },
38
+ "scripts": {
39
+ "watch": "tsc --build --watch",
40
+ "watch:test": "tsc --build tsconfig.spec.json --watch",
41
+ "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json",
42
+ "build": "rimraf dist && tsc --build && npm run resolve:aliases",
43
+ "test": "jest --passWithNoTests src",
44
+ "test:integration": "jest --forceExit --passWithNoTests"
45
+ },
46
+ "keywords": [
47
+ "medusa-providers",
48
+ "medusa-providers-cache"
49
+ ]
50
+ }