@medusajs/cache-redis 2.0.0-20230320210331
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.
- package/README.md +26 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/loaders/index.d.ts +3 -0
- package/dist/loaders/index.js +90 -0
- package/dist/loaders/index.js.map +1 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +9 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/redis-cache.d.ts +36 -0
- package/dist/services/redis-cache.js +137 -0
- package/dist/services/redis-cache.js.map +1 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +36 -0
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Medusa Cache Redis
|
|
2
|
+
|
|
3
|
+
Use Redis as a Medusa cache store.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
yarn add @medusajs/cache-redis
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Options
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
{
|
|
15
|
+
ttl?: number // Time to keep data in cache (in seconds)
|
|
16
|
+
|
|
17
|
+
redisUrl?: string // Redis instance connection string
|
|
18
|
+
|
|
19
|
+
redisOptions?: RedisOptions // Redis client options
|
|
20
|
+
|
|
21
|
+
namespace?: string // Prefix for event keys (the default is `medusa:`)
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Other caching modules
|
|
26
|
+
- [Medusa Cache In-Memory](../cache-inmemory/README.md)
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
var loaders_1 = __importDefault(require("./loaders"));
|
|
7
|
+
var services_1 = require("./services");
|
|
8
|
+
var service = services_1.RedisCacheService;
|
|
9
|
+
var loaders = [loaders_1.default];
|
|
10
|
+
var moduleDefinition = {
|
|
11
|
+
service: service,
|
|
12
|
+
loaders: loaders,
|
|
13
|
+
};
|
|
14
|
+
exports.default = moduleDefinition;
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAEA,sDAA8B;AAC9B,uCAA8C;AAE9C,IAAM,OAAO,GAAG,4BAAiB,CAAA;AACjC,IAAM,OAAO,GAAG,CAAC,iBAAM,CAAC,CAAA;AAExB,IAAM,gBAAgB,GAAkB;IACtC,OAAO,SAAA;IACP,OAAO,SAAA;CACR,CAAA;AAED,kBAAe,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var ioredis_1 = __importDefault(require("ioredis"));
|
|
54
|
+
var awilix_1 = require("awilix");
|
|
55
|
+
exports.default = (function (_a) {
|
|
56
|
+
var container = _a.container, logger = _a.logger, options = _a.options;
|
|
57
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
58
|
+
var _b, redisUrl, redisOptions, connection, err_1;
|
|
59
|
+
return __generator(this, function (_c) {
|
|
60
|
+
switch (_c.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
_b = options, redisUrl = _b.redisUrl, redisOptions = _b.redisOptions;
|
|
63
|
+
if (!redisUrl) {
|
|
64
|
+
throw Error("No `redisUrl` provided in `cacheService` module options. It is required for the Redis Cache Module.");
|
|
65
|
+
}
|
|
66
|
+
connection = new ioredis_1.default(redisUrl, __assign({
|
|
67
|
+
// Lazy connect to properly handle connection errors
|
|
68
|
+
lazyConnect: true }, (redisOptions !== null && redisOptions !== void 0 ? redisOptions : {})));
|
|
69
|
+
_c.label = 1;
|
|
70
|
+
case 1:
|
|
71
|
+
_c.trys.push([1, 3, , 4]);
|
|
72
|
+
return [4 /*yield*/, connection.connect()];
|
|
73
|
+
case 2:
|
|
74
|
+
_c.sent();
|
|
75
|
+
logger === null || logger === void 0 ? void 0 : logger.info("Connection to Redis in module 'cache-redis' established");
|
|
76
|
+
return [3 /*break*/, 4];
|
|
77
|
+
case 3:
|
|
78
|
+
err_1 = _c.sent();
|
|
79
|
+
logger === null || logger === void 0 ? void 0 : logger.error("An error occurred while connecting to Redis in module 'cache-redis': ".concat(err_1));
|
|
80
|
+
return [3 /*break*/, 4];
|
|
81
|
+
case 4:
|
|
82
|
+
container.register({
|
|
83
|
+
cacheRedisConnection: (0, awilix_1.asValue)(connection),
|
|
84
|
+
});
|
|
85
|
+
return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA2B;AAC3B,iCAAgC;AAKhC,mBAAe,UAAO,EAIN;QAHd,SAAS,eAAA,EACT,MAAM,YAAA,EACN,OAAO,aAAA;;;;;;oBAED,KAA6B,OAAkC,EAA7D,QAAQ,cAAA,EAAE,YAAY,kBAAA,CAAuC;oBAErE,IAAI,CAAC,QAAQ,EAAE;wBACb,MAAM,KAAK,CACT,qGAAqG,CACtG,CAAA;qBACF;oBAEK,UAAU,GAAG,IAAI,iBAAK,CAAC,QAAQ;wBACnC,oDAAoD;wBACpD,WAAW,EAAE,IAAI,IACd,CAAC,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,CAAC,EACvB,CAAA;;;;oBAGA,qBAAM,UAAU,CAAC,OAAO,EAAE,EAAA;;oBAA1B,SAA0B,CAAA;oBAC1B,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAC,yDAAyD,CAAC,CAAA;;;;oBAEvE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CACX,+EAAwE,KAAG,CAAE,CAC9E,CAAA;;;oBAGH,SAAS,CAAC,QAAQ,CAAC;wBACjB,oBAAoB,EAAE,IAAA,gBAAO,EAAC,UAAU,CAAC;qBAC1C,CAAC,CAAA;;;;;CACH,EAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as RedisCacheService } from "./redis-cache";
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
exports.RedisCacheService = void 0;
|
|
7
|
+
var redis_cache_1 = require("./redis-cache");
|
|
8
|
+
Object.defineProperty(exports, "RedisCacheService", { enumerable: true, get: function () { return __importDefault(redis_cache_1).default; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA4D;AAAnD,iIAAA,OAAO,OAAqB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Redis } from "ioredis";
|
|
2
|
+
import { ICacheService } from "@medusajs/medusa";
|
|
3
|
+
import { RedisCacheModuleOptions } from "../types";
|
|
4
|
+
declare type InjectedDependencies = {
|
|
5
|
+
cacheRedisConnection: Redis;
|
|
6
|
+
};
|
|
7
|
+
declare class RedisCacheService implements ICacheService {
|
|
8
|
+
protected readonly TTL: number;
|
|
9
|
+
protected readonly redis: Redis;
|
|
10
|
+
private readonly namespace;
|
|
11
|
+
constructor({ cacheRedisConnection }: InjectedDependencies, options?: RedisCacheModuleOptions);
|
|
12
|
+
/**
|
|
13
|
+
* Set a key/value pair to the cache.
|
|
14
|
+
* If the ttl is 0 it will act like the value should not be cached at all.
|
|
15
|
+
* @param key
|
|
16
|
+
* @param data
|
|
17
|
+
* @param ttl
|
|
18
|
+
*/
|
|
19
|
+
set(key: string, data: Record<string, unknown>, ttl?: number): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Retrieve a cached value belonging to the given key.
|
|
22
|
+
* @param cacheKey
|
|
23
|
+
*/
|
|
24
|
+
get<T>(cacheKey: string): Promise<T | null>;
|
|
25
|
+
/**
|
|
26
|
+
* Invalidate cache for a specific key. a key can be either a specific key or more global such as "ps:*".
|
|
27
|
+
* @param key
|
|
28
|
+
*/
|
|
29
|
+
invalidate(key: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Returns namespaced cache key
|
|
32
|
+
* @param key
|
|
33
|
+
*/
|
|
34
|
+
private getCacheKey;
|
|
35
|
+
}
|
|
36
|
+
export default RedisCacheService;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var DEFAULT_NAMESPACE = "medusa";
|
|
40
|
+
var DEFAULT_CACHE_TIME = 30; // 30 seconds
|
|
41
|
+
var EXPIRY_MODE = "EX"; // "EX" stands for an expiry time in second
|
|
42
|
+
var RedisCacheService = /** @class */ (function () {
|
|
43
|
+
function RedisCacheService(_a, options) {
|
|
44
|
+
var cacheRedisConnection = _a.cacheRedisConnection;
|
|
45
|
+
if (options === void 0) { options = {}; }
|
|
46
|
+
var _b;
|
|
47
|
+
this.redis = cacheRedisConnection;
|
|
48
|
+
this.TTL = (_b = options.ttl) !== null && _b !== void 0 ? _b : DEFAULT_CACHE_TIME;
|
|
49
|
+
this.namespace = options.namespace || DEFAULT_NAMESPACE;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Set a key/value pair to the cache.
|
|
53
|
+
* If the ttl is 0 it will act like the value should not be cached at all.
|
|
54
|
+
* @param key
|
|
55
|
+
* @param data
|
|
56
|
+
* @param ttl
|
|
57
|
+
*/
|
|
58
|
+
RedisCacheService.prototype.set = function (key, data, ttl) {
|
|
59
|
+
if (ttl === void 0) { ttl = this.TTL; }
|
|
60
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
+
return __generator(this, function (_a) {
|
|
62
|
+
switch (_a.label) {
|
|
63
|
+
case 0: return [4 /*yield*/, this.redis.set(this.getCacheKey(key), JSON.stringify(data), EXPIRY_MODE, ttl)];
|
|
64
|
+
case 1:
|
|
65
|
+
_a.sent();
|
|
66
|
+
return [2 /*return*/];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Retrieve a cached value belonging to the given key.
|
|
73
|
+
* @param cacheKey
|
|
74
|
+
*/
|
|
75
|
+
RedisCacheService.prototype.get = function (cacheKey) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
77
|
+
var cached, err_1;
|
|
78
|
+
return __generator(this, function (_a) {
|
|
79
|
+
switch (_a.label) {
|
|
80
|
+
case 0:
|
|
81
|
+
cacheKey = this.getCacheKey(cacheKey);
|
|
82
|
+
_a.label = 1;
|
|
83
|
+
case 1:
|
|
84
|
+
_a.trys.push([1, 3, , 5]);
|
|
85
|
+
return [4 /*yield*/, this.redis.get(cacheKey)];
|
|
86
|
+
case 2:
|
|
87
|
+
cached = _a.sent();
|
|
88
|
+
if (cached) {
|
|
89
|
+
return [2 /*return*/, JSON.parse(cached)];
|
|
90
|
+
}
|
|
91
|
+
return [3 /*break*/, 5];
|
|
92
|
+
case 3:
|
|
93
|
+
err_1 = _a.sent();
|
|
94
|
+
return [4 /*yield*/, this.redis.del(cacheKey)];
|
|
95
|
+
case 4:
|
|
96
|
+
_a.sent();
|
|
97
|
+
return [3 /*break*/, 5];
|
|
98
|
+
case 5: return [2 /*return*/, null];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Invalidate cache for a specific key. a key can be either a specific key or more global such as "ps:*".
|
|
105
|
+
* @param key
|
|
106
|
+
*/
|
|
107
|
+
RedisCacheService.prototype.invalidate = function (key) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
109
|
+
var keys, pipeline;
|
|
110
|
+
return __generator(this, function (_a) {
|
|
111
|
+
switch (_a.label) {
|
|
112
|
+
case 0: return [4 /*yield*/, this.redis.keys(this.getCacheKey(key))];
|
|
113
|
+
case 1:
|
|
114
|
+
keys = _a.sent();
|
|
115
|
+
pipeline = this.redis.pipeline();
|
|
116
|
+
keys.forEach(function (key) {
|
|
117
|
+
pipeline.del(key);
|
|
118
|
+
});
|
|
119
|
+
return [4 /*yield*/, pipeline.exec()];
|
|
120
|
+
case 2:
|
|
121
|
+
_a.sent();
|
|
122
|
+
return [2 /*return*/];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Returns namespaced cache key
|
|
129
|
+
* @param key
|
|
130
|
+
*/
|
|
131
|
+
RedisCacheService.prototype.getCacheKey = function (key) {
|
|
132
|
+
return this.namespace ? "".concat(this.namespace, ":").concat(key) : key;
|
|
133
|
+
};
|
|
134
|
+
return RedisCacheService;
|
|
135
|
+
}());
|
|
136
|
+
exports.default = RedisCacheService;
|
|
137
|
+
//# sourceMappingURL=redis-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-cache.js","sourceRoot":"","sources":["../../src/services/redis-cache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAM,iBAAiB,GAAG,QAAQ,CAAA;AAClC,IAAM,kBAAkB,GAAG,EAAE,CAAA,CAAC,aAAa;AAC3C,IAAM,WAAW,GAAG,IAAI,CAAA,CAAC,2CAA2C;AAMpE;IAKE,2BACE,EAA8C,EAC9C,OAAqC;YADnC,oBAAoB,0BAAA;QACtB,wBAAA,EAAA,YAAqC;;QAErC,IAAI,CAAC,KAAK,GAAG,oBAAoB,CAAA;QACjC,IAAI,CAAC,GAAG,GAAG,MAAA,OAAO,CAAC,GAAG,mCAAI,kBAAkB,CAAA;QAC5C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,iBAAiB,CAAA;IACzD,CAAC;IACD;;;;;;OAMG;IACG,+BAAG,GAAT,UACE,GAAW,EACX,IAA6B,EAC7B,GAAsB;QAAtB,oBAAA,EAAA,MAAc,IAAI,CAAC,GAAG;;;;4BAEtB,qBAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAClB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EACrB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EACpB,WAAW,EACX,GAAG,CACJ,EAAA;;wBALD,SAKC,CAAA;;;;;KACF;IAED;;;OAGG;IACG,+BAAG,GAAT,UAAa,QAAgB;;;;;;wBAC3B,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;;;;wBAEpB,qBAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAA;;wBAAvC,MAAM,GAAG,SAA8B;wBAC7C,IAAI,MAAM,EAAE;4BACV,sBAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAA;yBAC1B;;;;wBAED,qBAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAA;;wBAA9B,SAA8B,CAAA;;4BAEhC,sBAAO,IAAI,EAAA;;;;KACZ;IAED;;;OAGG;IACG,sCAAU,GAAhB,UAAiB,GAAW;;;;;4BACb,qBAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAA;;wBAAnD,IAAI,GAAG,SAA4C;wBACnD,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAA;wBAEtC,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG;4BACxB,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;wBACnB,CAAC,CAAC,CAAA;wBAEF,qBAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;wBAArB,SAAqB,CAAA;;;;;KACtB;IAED;;;OAGG;IACK,uCAAW,GAAnB,UAAoB,GAAW;QAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,UAAG,IAAI,CAAC,SAAS,cAAI,GAAG,CAAE,CAAC,CAAC,CAAC,GAAG,CAAA;IAC1D,CAAC;IACH,wBAAC;AAAD,CAAC,AAxED,IAwEC;AAED,kBAAe,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RedisOptions } from "ioredis";
|
|
2
|
+
/**
|
|
3
|
+
* Module config type
|
|
4
|
+
*/
|
|
5
|
+
export declare type RedisCacheModuleOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Time to keep data in cache (in seconds)
|
|
8
|
+
*/
|
|
9
|
+
ttl?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Redis connection string
|
|
12
|
+
*/
|
|
13
|
+
redisUrl?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Redis client options
|
|
16
|
+
*/
|
|
17
|
+
redisOptions?: RedisOptions;
|
|
18
|
+
/**
|
|
19
|
+
* Prefix for event keys
|
|
20
|
+
* @default `medusa:`
|
|
21
|
+
*/
|
|
22
|
+
namespace?: string;
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@medusajs/cache-redis",
|
|
3
|
+
"version": "2.0.0-20230320210331",
|
|
4
|
+
"description": "Redis Cache Module for Medusa",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/medusajs/medusa",
|
|
9
|
+
"directory": "packages/cache-redis"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"author": "Medusa",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@medusajs/medusa": "2.0.0-20230320210331",
|
|
21
|
+
"cross-env": "^5.2.1",
|
|
22
|
+
"jest": "^25.5.4",
|
|
23
|
+
"ts-jest": "^25.5.1",
|
|
24
|
+
"typescript": "^4.4.4"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"watch": "tsc --build --watch",
|
|
28
|
+
"prepare": "cross-env NODE_ENV=production yarn run build",
|
|
29
|
+
"build": "tsc --build",
|
|
30
|
+
"test": "jest --passWithNoTests",
|
|
31
|
+
"test:unit": "jest --passWithNoTests"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@medusajs/medusa": "2.0.0-20230320210331"
|
|
35
|
+
}
|
|
36
|
+
}
|