@medusajs/cache-inmemory 2.0.0-snapshot-20230313175443 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +3 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/dist/initialize/index.d.ts +4 -0
- package/dist/initialize/index.d.ts.map +1 -0
- package/dist/initialize/index.js +16 -0
- package/dist/initialize/index.js.map +1 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/inmemory-cache.d.ts +3 -3
- package/dist/services/inmemory-cache.d.ts.map +1 -0
- package/dist/services/inmemory-cache.js +50 -111
- package/dist/services/inmemory-cache.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +17 -12
package/README.md
CHANGED
@@ -17,7 +17,9 @@ yarn add @medusajs/cache-inmemory
|
|
17
17
|
```
|
18
18
|
|
19
19
|
### Note
|
20
|
-
|
20
|
+
|
21
|
+
Recommended for testing and development. For production, use Redis cache module.
|
21
22
|
|
22
23
|
### Other caching modules
|
24
|
+
|
23
25
|
- [Medusa Cache Redis](../cache-redis/README.md)
|
package/dist/index.d.ts
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
-
import { ModuleExports } from "@medusajs/
|
1
|
+
import { ModuleExports } from "@medusajs/framework/types";
|
2
2
|
declare const moduleDefinition: ModuleExports;
|
3
3
|
export default moduleDefinition;
|
4
|
+
export * from "./initialize";
|
5
|
+
export * from "./types";
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAKzD,QAAA,MAAM,gBAAgB,EAAE,aAEvB,CAAA;AAED,eAAe,gBAAgB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
@@ -1,14 +1,28 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
2
16
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
18
|
};
|
5
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
service: service,
|
11
|
-
loaders: loaders,
|
20
|
+
const inmemory_cache_1 = __importDefault(require("./services/inmemory-cache"));
|
21
|
+
const service = inmemory_cache_1.default;
|
22
|
+
const moduleDefinition = {
|
23
|
+
service,
|
12
24
|
};
|
13
25
|
exports.default = moduleDefinition;
|
26
|
+
__exportStar(require("./initialize"), exports);
|
27
|
+
__exportStar(require("./types"), exports);
|
14
28
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AACA,+EAA4D;AAE5D,MAAM,OAAO,GAAG,wBAAoB,CAAA;AAEpC,MAAM,gBAAgB,GAAkB;IACtC,OAAO;CACR,CAAA;AAED,kBAAe,gBAAgB,CAAA;AAC/B,+CAA4B;AAC5B,0CAAuB"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { ExternalModuleDeclaration, ICacheService } from "@medusajs/framework/types";
|
2
|
+
import { InMemoryCacheModuleOptions } from "../types";
|
3
|
+
export declare const initialize: (options?: InMemoryCacheModuleOptions | ExternalModuleDeclaration) => Promise<ICacheService>;
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/initialize/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,aAAa,EAEd,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAA;AAErD,eAAO,MAAM,UAAU,aACX,0BAA0B,GAAG,yBAAyB,KAC/D,OAAO,CAAC,aAAa,CAWvB,CAAA"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.initialize = void 0;
|
4
|
+
const modules_sdk_1 = require("@medusajs/framework/modules-sdk");
|
5
|
+
const utils_1 = require("@medusajs/framework/utils");
|
6
|
+
const initialize = async (options) => {
|
7
|
+
const serviceKey = utils_1.Modules.CACHE;
|
8
|
+
const loaded = await modules_sdk_1.MedusaModule.bootstrap({
|
9
|
+
moduleKey: serviceKey,
|
10
|
+
defaultPath: "@medusajs//cache-inmemory",
|
11
|
+
declaration: options,
|
12
|
+
});
|
13
|
+
return loaded[serviceKey];
|
14
|
+
};
|
15
|
+
exports.initialize = initialize;
|
16
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/initialize/index.ts"],"names":[],"mappings":";;;AAAA,iEAA8D;AAM9D,qDAAmD;AAG5C,MAAM,UAAU,GAAG,KAAK,EAC7B,OAAgE,EACxC,EAAE;IAC1B,MAAM,UAAU,GAAG,eAAO,CAAC,KAAK,CAAA;IAChC,MAAM,MAAM,GAAG,MAAM,0BAAY,CAAC,SAAS,CAAgB;QACzD,SAAS,EAAE,UAAU;QACrB,WAAW,EAAE,2BAA2B;QACxC,WAAW,EAAE,OAEgB;KAC9B,CAAC,CAAA;IAEF,OAAO,MAAM,CAAC,UAAU,CAAC,CAAA;AAC3B,CAAC,CAAA;AAbY,QAAA,UAAU,cAatB"}
|
package/dist/services/index.d.ts
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,kBAAkB,CAAA"}
|
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
|
-
import { ICacheService } from "@medusajs/medusa";
|
1
|
+
import { ICacheService } from "@medusajs/framework/types";
|
3
2
|
import { CacheRecord, InMemoryCacheModuleOptions } from "../types";
|
4
|
-
|
3
|
+
type InjectedDependencies = {};
|
5
4
|
/**
|
6
5
|
* Class represents basic, in-memory, cache store.
|
7
6
|
*/
|
@@ -35,3 +34,4 @@ declare class InMemoryCacheService implements ICacheService {
|
|
35
34
|
clear(): Promise<void>;
|
36
35
|
}
|
37
36
|
export default InMemoryCacheService;
|
37
|
+
//# sourceMappingURL=inmemory-cache.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"inmemory-cache.d.ts","sourceRoot":"","sources":["../../src/services/inmemory-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAA;AAIlE,KAAK,oBAAoB,GAAG,EAAE,CAAA;AAE9B;;GAEG;AACH,cAAM,oBAAqB,YAAW,aAAa;IACjD,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IAE9B,SAAS,CAAC,QAAQ,CAAC,KAAK,gCAAsC;IAC9D,SAAS,CAAC,QAAQ,CAAC,UAAU,8BAAoC;gBAG/D,IAAI,EAAE,oBAAoB,EAC1B,OAAO,GAAE,0BAA+B;IAK1C;;;OAGG;IACG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAa5C;;;;;OAKG;IACG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,GAAE,MAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBzE;;;;;OAKG;IACG,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB5C;;OAEG;IACG,KAAK;CAMZ;AAED,eAAe,oBAAoB,CAAA"}
|
@@ -1,141 +1,80 @@
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
-
|
3
|
+
const DEFAULT_TTL = 30; // seconds
|
40
4
|
/**
|
41
5
|
* Class represents basic, in-memory, cache store.
|
42
6
|
*/
|
43
|
-
|
44
|
-
|
45
|
-
if (options === void 0) { options = {}; }
|
46
|
-
var _a;
|
7
|
+
class InMemoryCacheService {
|
8
|
+
constructor(deps, options = {}) {
|
47
9
|
this.store = new Map();
|
48
10
|
this.timoutRefs = new Map();
|
49
|
-
this.TTL =
|
11
|
+
this.TTL = options.ttl ?? DEFAULT_TTL;
|
50
12
|
}
|
51
13
|
/**
|
52
14
|
* Retrieve data from the cache.
|
53
15
|
* @param key - cache key
|
54
16
|
*/
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
return [2 /*return*/, null];
|
65
|
-
}
|
66
|
-
return [2 /*return*/, record.data];
|
67
|
-
});
|
68
|
-
});
|
69
|
-
};
|
17
|
+
async get(key) {
|
18
|
+
const now = Date.now();
|
19
|
+
const record = this.store.get(key);
|
20
|
+
const recordExpire = record?.expire ?? Infinity;
|
21
|
+
if (!record || recordExpire < now) {
|
22
|
+
return null;
|
23
|
+
}
|
24
|
+
return record.data;
|
25
|
+
}
|
70
26
|
/**
|
71
27
|
* Set data to the cache.
|
72
28
|
* @param key - cache key under which the data is stored
|
73
29
|
* @param data - data to be stored in the cache
|
74
30
|
* @param ttl - expiration time in seconds
|
75
31
|
*/
|
76
|
-
|
77
|
-
if (ttl ===
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
return [2 /*return*/];
|
94
|
-
});
|
95
|
-
});
|
96
|
-
};
|
32
|
+
async set(key, data, ttl = this.TTL) {
|
33
|
+
if (ttl === 0) {
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
const record = { data, expire: ttl * 1000 + Date.now() };
|
37
|
+
const oldRecord = this.store.get(key);
|
38
|
+
if (oldRecord) {
|
39
|
+
clearTimeout(this.timoutRefs.get(key));
|
40
|
+
this.timoutRefs.delete(key);
|
41
|
+
}
|
42
|
+
const ref = setTimeout(async () => {
|
43
|
+
await this.invalidate(key);
|
44
|
+
}, ttl * 1000);
|
45
|
+
ref.unref();
|
46
|
+
this.timoutRefs.set(key, ref);
|
47
|
+
this.store.set(key, record);
|
48
|
+
}
|
97
49
|
/**
|
98
50
|
* Delete data from the cache.
|
99
51
|
* Could use wildcard (*) matcher e.g. `invalidate("ps:*")` to delete all keys that start with "ps:"
|
100
52
|
*
|
101
53
|
* @param key - cache key
|
102
54
|
*/
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
clearTimeout(timeoutRef);
|
117
|
-
_this.timoutRefs.delete(key);
|
118
|
-
}
|
119
|
-
_this.store.delete(key);
|
120
|
-
});
|
121
|
-
return [2 /*return*/];
|
122
|
-
});
|
55
|
+
async invalidate(key) {
|
56
|
+
let keys = [key];
|
57
|
+
if (key.includes("*")) {
|
58
|
+
const regExp = new RegExp(key.replace("*", ".*"));
|
59
|
+
keys = Array.from(this.store.keys()).filter((k) => k.match(regExp));
|
60
|
+
}
|
61
|
+
keys.forEach((key) => {
|
62
|
+
const timeoutRef = this.timoutRefs.get(key);
|
63
|
+
if (timeoutRef) {
|
64
|
+
clearTimeout(timeoutRef);
|
65
|
+
this.timoutRefs.delete(key);
|
66
|
+
}
|
67
|
+
this.store.delete(key);
|
123
68
|
});
|
124
|
-
}
|
69
|
+
}
|
125
70
|
/**
|
126
71
|
* Delete the entire cache.
|
127
72
|
*/
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
return [2 /*return*/];
|
135
|
-
});
|
136
|
-
});
|
137
|
-
};
|
138
|
-
return InMemoryCacheService;
|
139
|
-
}());
|
73
|
+
async clear() {
|
74
|
+
this.timoutRefs.forEach((ref) => clearTimeout(ref));
|
75
|
+
this.timoutRefs.clear();
|
76
|
+
this.store.clear();
|
77
|
+
}
|
78
|
+
}
|
140
79
|
exports.default = InMemoryCacheService;
|
141
80
|
//# sourceMappingURL=inmemory-cache.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"inmemory-cache.js","sourceRoot":"","sources":["../../src/services/inmemory-cache.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"inmemory-cache.js","sourceRoot":"","sources":["../../src/services/inmemory-cache.ts"],"names":[],"mappings":"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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"root":["../src/index.ts","../src/initialize/index.ts","../src/services/index.ts","../src/services/inmemory-cache.ts","../src/services/__tests__/inmemory-cache.js","../src/types/index.ts"],"version":"5.6.2"}
|
package/dist/types/index.d.ts
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
/**
|
2
2
|
* Shape of a record saved in `in-memory` cache
|
3
3
|
*/
|
4
|
-
export
|
4
|
+
export type CacheRecord<T> = {
|
5
5
|
data: T;
|
6
6
|
/**
|
7
7
|
* Timestamp in milliseconds
|
8
8
|
*/
|
9
9
|
expire: number;
|
10
10
|
};
|
11
|
-
export
|
11
|
+
export type InMemoryCacheModuleOptions = {
|
12
12
|
/**
|
13
13
|
* Time to keep data in cache (in seconds)
|
14
14
|
*/
|
15
15
|
ttl?: number;
|
16
16
|
};
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,IAAI,EAAE,CAAC,CAAA;IACP;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@medusajs/cache-inmemory",
|
3
|
-
"version": "2.0.0
|
3
|
+
"version": "2.0.0",
|
4
4
|
"description": "In-memory Cache Module for Medusa",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"repository": {
|
@@ -8,29 +8,34 @@
|
|
8
8
|
"url": "https://github.com/medusajs/medusa",
|
9
9
|
"directory": "packages/cache-inmemory"
|
10
10
|
},
|
11
|
+
"engines": {
|
12
|
+
"node": ">=20"
|
13
|
+
},
|
11
14
|
"publishConfig": {
|
12
15
|
"access": "public"
|
13
16
|
},
|
14
17
|
"files": [
|
15
|
-
"dist"
|
18
|
+
"dist",
|
19
|
+
"!dist/**/__tests__",
|
20
|
+
"!dist/**/__mocks__",
|
21
|
+
"!dist/**/__fixtures__"
|
16
22
|
],
|
17
23
|
"author": "Medusa",
|
18
24
|
"license": "MIT",
|
19
25
|
"devDependencies": {
|
20
|
-
"@medusajs/
|
21
|
-
"
|
22
|
-
"jest": "^
|
23
|
-
"
|
24
|
-
"
|
26
|
+
"@medusajs/framework": "^2.0.0",
|
27
|
+
"@swc/core": "^1.7.28",
|
28
|
+
"@swc/jest": "^0.2.36",
|
29
|
+
"jest": "^29.7.0",
|
30
|
+
"rimraf": "^5.0.1",
|
31
|
+
"typescript": "^5.6.2"
|
25
32
|
},
|
26
33
|
"scripts": {
|
27
34
|
"watch": "tsc --build --watch",
|
28
|
-
"
|
29
|
-
"
|
30
|
-
"test": "jest --passWithNoTests",
|
31
|
-
"test:unit": "jest --passWithNoTests"
|
35
|
+
"build": "rimraf dist && tsc --build",
|
36
|
+
"test": "jest --passWithNoTests"
|
32
37
|
},
|
33
38
|
"peerDependencies": {
|
34
|
-
"@medusajs/
|
39
|
+
"@medusajs/framework": "^2.0.0"
|
35
40
|
}
|
36
41
|
}
|