koatty_cacheable 1.4.0 → 1.4.2
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/CHANGELOG.md +10 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -5
- package/dist/index.mjs +19 -5
- package/dist/package.json +7 -6
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.4.2](https://github.com/thinkkoa/koatty_cacheable/compare/v1.4.1...v1.4.2) (2023-12-20)
|
|
6
|
+
|
|
7
|
+
### [1.4.1](https://github.com/thinkkoa/koatty_cacheable/compare/v1.4.0...v1.4.1) (2023-08-04)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* default value ([38f2e57](https://github.com/thinkkoa/koatty_cacheable/commit/38f2e57d52d13482907ca9eac6006d1e841bdadd))
|
|
13
|
+
* 初始化缓存改为appReady执行 ([7e9b1ab](https://github.com/thinkkoa/koatty_cacheable/commit/7e9b1abe6acdbdf1b6ad34efa053cbaca1e7b6d7))
|
|
14
|
+
|
|
5
15
|
## [1.4.0](https://github.com/thinkkoa/koatty_cacheable/compare/v1.3.8...v1.4.0) (2023-02-18)
|
|
6
16
|
|
|
7
17
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @Author: richen
|
|
3
|
-
* @Date: 2023-
|
|
3
|
+
* @Date: 2023-12-20 19:24:38
|
|
4
4
|
* @License: BSD (3-Clause)
|
|
5
5
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
|
6
6
|
* @HomePage: https://koatty.org/
|
|
@@ -15,7 +15,7 @@ var koatty_container = require('koatty_container');
|
|
|
15
15
|
/*
|
|
16
16
|
* @Author: richen
|
|
17
17
|
* @Date: 2020-07-06 19:53:43
|
|
18
|
-
* @LastEditTime: 2023-
|
|
18
|
+
* @LastEditTime: 2023-08-04 14:33:58
|
|
19
19
|
* @Description:
|
|
20
20
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
|
21
21
|
*/
|
|
@@ -32,11 +32,11 @@ const storeCache = {
|
|
|
32
32
|
* @returns {*} {CacheStore}
|
|
33
33
|
*/
|
|
34
34
|
async function GetCacheStore(app) {
|
|
35
|
-
var _a;
|
|
35
|
+
var _a, _b;
|
|
36
36
|
if (storeCache.store && storeCache.store.getConnection) {
|
|
37
37
|
return storeCache.store;
|
|
38
38
|
}
|
|
39
|
-
const opt = (_a = app.config("CacheStore", "db")) !== null &&
|
|
39
|
+
const opt = (_b = (_a = app.config("CacheStore")) !== null && _a !== void 0 ? _a : app.config("CacheStore", "db")) !== null && _b !== void 0 ? _b : {};
|
|
40
40
|
if (koatty_lib.Helper.isEmpty(opt)) {
|
|
41
41
|
koatty_logger.DefaultLogger.Warn(`Missing CacheStore server configuration. Please write a configuration item with the key name 'CacheStore' in the db.ts file.`);
|
|
42
42
|
}
|
|
@@ -52,8 +52,11 @@ async function GetCacheStore(app) {
|
|
|
52
52
|
*
|
|
53
53
|
*/
|
|
54
54
|
async function InitCacheStore() {
|
|
55
|
+
if (storeCache.store !== null) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
55
58
|
const app = koatty_container.IOCContainer.getApp();
|
|
56
|
-
app && app.once("
|
|
59
|
+
app && app.once("appReady", async function () {
|
|
57
60
|
await GetCacheStore(app);
|
|
58
61
|
});
|
|
59
62
|
}
|
|
@@ -83,6 +86,12 @@ function CacheAble(cacheName, opt = {
|
|
|
83
86
|
throw Error("This decorator only used in the service、component class.");
|
|
84
87
|
}
|
|
85
88
|
const { value, configurable, enumerable } = descriptor;
|
|
89
|
+
opt = {
|
|
90
|
+
...{
|
|
91
|
+
params: [],
|
|
92
|
+
timeout: 3600,
|
|
93
|
+
}, ...opt
|
|
94
|
+
};
|
|
86
95
|
// 获取定义的参数位置
|
|
87
96
|
const paramIndexes = getParamIndex(opt.params, getArgs(value));
|
|
88
97
|
descriptor = {
|
|
@@ -164,6 +173,11 @@ function CacheEvict(cacheName, opt = {
|
|
|
164
173
|
}
|
|
165
174
|
const { value, configurable, enumerable } = descriptor;
|
|
166
175
|
// 获取定义的参数位置
|
|
176
|
+
opt = {
|
|
177
|
+
...{
|
|
178
|
+
eventTime: "Before",
|
|
179
|
+
}, ...opt
|
|
180
|
+
};
|
|
167
181
|
const paramIndexes = getParamIndex(opt.params, getArgs(value));
|
|
168
182
|
descriptor = {
|
|
169
183
|
configurable,
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @Author: richen
|
|
3
|
-
* @Date: 2023-
|
|
3
|
+
* @Date: 2023-12-20 19:24:38
|
|
4
4
|
* @License: BSD (3-Clause)
|
|
5
5
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
|
6
6
|
* @HomePage: https://koatty.org/
|
|
@@ -13,7 +13,7 @@ import { IOCContainer } from 'koatty_container';
|
|
|
13
13
|
/*
|
|
14
14
|
* @Author: richen
|
|
15
15
|
* @Date: 2020-07-06 19:53:43
|
|
16
|
-
* @LastEditTime: 2023-
|
|
16
|
+
* @LastEditTime: 2023-08-04 14:33:58
|
|
17
17
|
* @Description:
|
|
18
18
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
|
19
19
|
*/
|
|
@@ -30,11 +30,11 @@ const storeCache = {
|
|
|
30
30
|
* @returns {*} {CacheStore}
|
|
31
31
|
*/
|
|
32
32
|
async function GetCacheStore(app) {
|
|
33
|
-
var _a;
|
|
33
|
+
var _a, _b;
|
|
34
34
|
if (storeCache.store && storeCache.store.getConnection) {
|
|
35
35
|
return storeCache.store;
|
|
36
36
|
}
|
|
37
|
-
const opt = (_a = app.config("CacheStore", "db")) !== null &&
|
|
37
|
+
const opt = (_b = (_a = app.config("CacheStore")) !== null && _a !== void 0 ? _a : app.config("CacheStore", "db")) !== null && _b !== void 0 ? _b : {};
|
|
38
38
|
if (Helper.isEmpty(opt)) {
|
|
39
39
|
DefaultLogger.Warn(`Missing CacheStore server configuration. Please write a configuration item with the key name 'CacheStore' in the db.ts file.`);
|
|
40
40
|
}
|
|
@@ -50,8 +50,11 @@ async function GetCacheStore(app) {
|
|
|
50
50
|
*
|
|
51
51
|
*/
|
|
52
52
|
async function InitCacheStore() {
|
|
53
|
+
if (storeCache.store !== null) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
53
56
|
const app = IOCContainer.getApp();
|
|
54
|
-
app && app.once("
|
|
57
|
+
app && app.once("appReady", async function () {
|
|
55
58
|
await GetCacheStore(app);
|
|
56
59
|
});
|
|
57
60
|
}
|
|
@@ -81,6 +84,12 @@ function CacheAble(cacheName, opt = {
|
|
|
81
84
|
throw Error("This decorator only used in the service、component class.");
|
|
82
85
|
}
|
|
83
86
|
const { value, configurable, enumerable } = descriptor;
|
|
87
|
+
opt = {
|
|
88
|
+
...{
|
|
89
|
+
params: [],
|
|
90
|
+
timeout: 3600,
|
|
91
|
+
}, ...opt
|
|
92
|
+
};
|
|
84
93
|
// 获取定义的参数位置
|
|
85
94
|
const paramIndexes = getParamIndex(opt.params, getArgs(value));
|
|
86
95
|
descriptor = {
|
|
@@ -162,6 +171,11 @@ function CacheEvict(cacheName, opt = {
|
|
|
162
171
|
}
|
|
163
172
|
const { value, configurable, enumerable } = descriptor;
|
|
164
173
|
// 获取定义的参数位置
|
|
174
|
+
opt = {
|
|
175
|
+
...{
|
|
176
|
+
eventTime: "Before",
|
|
177
|
+
}, ...opt
|
|
178
|
+
};
|
|
165
179
|
const paramIndexes = getParamIndex(opt.params, getArgs(value));
|
|
166
180
|
descriptor = {
|
|
167
181
|
configurable,
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koatty_cacheable",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Cacheable for koatty.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"build:doc": "del-cli --force docs/api && npx api-documenter markdown --input temp --output docs/api",
|
|
10
10
|
"build:dts": "del-cli --force temp && npx tsc && npx api-extractor run --local --verbose",
|
|
11
11
|
"eslint": "eslint --ext .ts,.js ./",
|
|
12
|
-
"
|
|
12
|
+
"lock": "npm i --package-lock-only",
|
|
13
|
+
"prepublishOnly": "npm test && npm run build && git push --follow-tags origin",
|
|
13
14
|
"prerelease": "npm test && npm run build",
|
|
14
|
-
"pub": "git push --follow-tags origin && npm publish",
|
|
15
15
|
"release": "standard-version",
|
|
16
16
|
"release:pre": "npm run release -- --prerelease",
|
|
17
17
|
"release:major": "npm run release -- --release-as major",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@rollup/plugin-json": "^6.x.x",
|
|
60
60
|
"@types/jest": "^29.x.x",
|
|
61
61
|
"@types/koa": "^2.x.x",
|
|
62
|
+
"@types/lodash": "^4.x.x",
|
|
62
63
|
"@types/node": "^18.x.x",
|
|
63
64
|
"@typescript-eslint/eslint-plugin": "^5.x.x",
|
|
64
65
|
"@typescript-eslint/parser": "^5.x.x",
|
|
@@ -75,18 +76,18 @@
|
|
|
75
76
|
"standard-version": "^9.x.x",
|
|
76
77
|
"ts-jest": "^29.x.x",
|
|
77
78
|
"ts-node": "^10.x.x",
|
|
79
|
+
"tslib": "^2.x.x",
|
|
78
80
|
"typescript": "^4.x.x"
|
|
79
81
|
},
|
|
80
82
|
"dependencies": {
|
|
81
83
|
"koatty_container": "^1.x.x",
|
|
82
84
|
"koatty_lib": "^1.x.x",
|
|
83
85
|
"koatty_logger": "^2.x.x",
|
|
84
|
-
"koatty_store": "^1.
|
|
86
|
+
"koatty_store": "^1.6.2"
|
|
85
87
|
},
|
|
86
88
|
"peerDependencies": {
|
|
87
89
|
"koatty_container": "^1.x.x",
|
|
88
90
|
"koatty_lib": "^1.x.x",
|
|
89
|
-
"koatty_logger": "^2.x.x"
|
|
90
|
-
"koatty_store": "^1.x.x"
|
|
91
|
+
"koatty_logger": "^2.x.x"
|
|
91
92
|
}
|
|
92
93
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koatty_cacheable",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Cacheable for koatty.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"build:doc": "del-cli --force docs/api && npx api-documenter markdown --input temp --output docs/api",
|
|
10
10
|
"build:dts": "del-cli --force temp && npx tsc && npx api-extractor run --local --verbose",
|
|
11
11
|
"eslint": "eslint --ext .ts,.js ./",
|
|
12
|
-
"
|
|
12
|
+
"lock": "npm i --package-lock-only",
|
|
13
|
+
"prepublishOnly": "npm test && npm run build && git push --follow-tags origin",
|
|
13
14
|
"prerelease": "npm test && npm run build",
|
|
14
|
-
"pub": "git push --follow-tags origin && npm publish",
|
|
15
15
|
"release": "standard-version",
|
|
16
16
|
"release:pre": "npm run release -- --prerelease",
|
|
17
17
|
"release:major": "npm run release -- --release-as major",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@rollup/plugin-json": "^6.x.x",
|
|
60
60
|
"@types/jest": "^29.x.x",
|
|
61
61
|
"@types/koa": "^2.x.x",
|
|
62
|
+
"@types/lodash": "^4.x.x",
|
|
62
63
|
"@types/node": "^18.x.x",
|
|
63
64
|
"@typescript-eslint/eslint-plugin": "^5.x.x",
|
|
64
65
|
"@typescript-eslint/parser": "^5.x.x",
|
|
@@ -75,18 +76,18 @@
|
|
|
75
76
|
"standard-version": "^9.x.x",
|
|
76
77
|
"ts-jest": "^29.x.x",
|
|
77
78
|
"ts-node": "^10.x.x",
|
|
79
|
+
"tslib": "^2.x.x",
|
|
78
80
|
"typescript": "^4.x.x"
|
|
79
81
|
},
|
|
80
82
|
"dependencies": {
|
|
81
83
|
"koatty_container": "^1.x.x",
|
|
82
84
|
"koatty_lib": "^1.x.x",
|
|
83
85
|
"koatty_logger": "^2.x.x",
|
|
84
|
-
"koatty_store": "^1.
|
|
86
|
+
"koatty_store": "^1.6.2"
|
|
85
87
|
},
|
|
86
88
|
"peerDependencies": {
|
|
87
89
|
"koatty_container": "^1.x.x",
|
|
88
90
|
"koatty_lib": "^1.x.x",
|
|
89
|
-
"koatty_logger": "^2.x.x"
|
|
90
|
-
"koatty_store": "^1.x.x"
|
|
91
|
+
"koatty_logger": "^2.x.x"
|
|
91
92
|
}
|
|
92
93
|
}
|