koatty_cacheable 1.4.0 → 1.4.1

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 CHANGED
@@ -2,6 +2,14 @@
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.1](https://github.com/thinkkoa/koatty_cacheable/compare/v1.4.0...v1.4.1) (2023-08-04)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * default value ([38f2e57](https://github.com/thinkkoa/koatty_cacheable/commit/38f2e57d52d13482907ca9eac6006d1e841bdadd))
11
+ * 初始化缓存改为appReady执行 ([7e9b1ab](https://github.com/thinkkoa/koatty_cacheable/commit/7e9b1abe6acdbdf1b6ad34efa053cbaca1e7b6d7))
12
+
5
13
  ## [1.4.0](https://github.com/thinkkoa/koatty_cacheable/compare/v1.3.8...v1.4.0) (2023-02-18)
6
14
 
7
15
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2023-02-19 01:22:50
3
+ * @Date: 2023-08-04 14:37:52
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2023-02-19 01:22:36
3
+ * @Date: 2023-08-04 14:37:39
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-02-19 01:16:52
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 && _a !== void 0 ? _a : {};
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("appStart", async function () {
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-02-19 01:22:36
3
+ * @Date: 2023-08-04 14:37:39
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-02-19 01:16:52
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 && _a !== void 0 ? _a : {};
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("appStart", async function () {
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.0",
3
+ "version": "1.4.1",
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,8 @@
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
- "prepublishOnly": "npm test && npm run build",
12
+ "prepublishOnly": "npm test && npm run build && git push --follow-tags origin",
13
13
  "prerelease": "npm test && npm run build",
14
- "pub": "git push --follow-tags origin && npm publish",
15
14
  "release": "standard-version",
16
15
  "release:pre": "npm run release -- --prerelease",
17
16
  "release:major": "npm run release -- --release-as major",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koatty_cacheable",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
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,8 @@
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
- "prepublishOnly": "npm test && npm run build",
12
+ "prepublishOnly": "npm test && npm run build && git push --follow-tags origin",
13
13
  "prerelease": "npm test && npm run build",
14
- "pub": "git push --follow-tags origin && npm publish",
15
14
  "release": "standard-version",
16
15
  "release:pre": "npm run release -- --prerelease",
17
16
  "release:major": "npm run release -- --release-as major",