koatty_cacheable 1.3.6 → 1.3.8

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/dist/index.mjs ADDED
@@ -0,0 +1,173 @@
1
+ /*!
2
+ * @Author: richen
3
+ * @Date: 2023-01-13 14:17:07
4
+ * @License: BSD (3-Clause)
5
+ * @Copyright (c) - <richenlin(at)gmail.com>
6
+ * @HomePage: https://koatty.org/
7
+ */
8
+ import * as helper from 'koatty_lib';
9
+ import { DefaultLogger } from 'koatty_logger';
10
+ import { Store } from 'koatty_store';
11
+ import { IOCContainer } from 'koatty_container';
12
+
13
+ /*
14
+ * @Author: richen
15
+ * @Date: 2020-07-06 19:53:43
16
+ * @LastEditTime: 2023-01-13 14:16:02
17
+ * @Description:
18
+ * @Copyright (c) - <richenlin(at)gmail.com>
19
+ */
20
+ // cacheStore
21
+ const cacheStore = {
22
+ store: null
23
+ };
24
+ /**
25
+ * get instances of cacheStore
26
+ *
27
+ * @export
28
+ * @param {Application} app
29
+ * @returns {*} {CacheStore}
30
+ */
31
+ async function GetCacheStore(app) {
32
+ var _a;
33
+ if (cacheStore.store && cacheStore.store.getConnection) {
34
+ return cacheStore.store;
35
+ }
36
+ const opt = (_a = app.config("CacheStore", "db")) !== null && _a !== void 0 ? _a : {};
37
+ if (helper.isEmpty(opt)) {
38
+ DefaultLogger.Warn(`Missing CacheStore server configuration. Please write a configuration item with the key name 'CacheStore' in the db.ts file.`);
39
+ }
40
+ cacheStore.store = Store.getInstance(opt);
41
+ if (!helper.isFunction(cacheStore.store.getConnection)) {
42
+ throw Error(`CacheStore connection failed. `);
43
+ }
44
+ return cacheStore.store;
45
+ }
46
+ /**
47
+ * initiation CacheStore connection and client.
48
+ *
49
+ */
50
+ async function InitCacheStore() {
51
+ const app = IOCContainer.getApp();
52
+ app && app.once("appStart", async function () {
53
+ await GetCacheStore(app);
54
+ });
55
+ }
56
+ /**
57
+ * Decorate this method to support caching. Redis server config from db.ts.
58
+ * The cache method returns a value to ensure that the next time the method is executed with the same parameters,
59
+ * the results can be obtained directly from the cache without the need to execute the method again.
60
+ *
61
+ * @export
62
+ * @param {string} cacheName cache name
63
+ * @param {number} [timeout=3600] cache timeout
64
+ * @returns {MethodDecorator}
65
+ */
66
+ function CacheAble(cacheName, timeout = 3600) {
67
+ return (target, methodName, descriptor) => {
68
+ const componentType = IOCContainer.getType(target);
69
+ if (componentType !== "SERVICE" && componentType !== "COMPONENT") {
70
+ throw Error("This decorator only used in the service、component class.");
71
+ }
72
+ let identifier = IOCContainer.getIdentifier(target);
73
+ identifier = identifier || (target.constructor ? (target.constructor.name || "") : "");
74
+ const { value, configurable, enumerable } = descriptor;
75
+ descriptor = {
76
+ configurable,
77
+ enumerable,
78
+ writable: true,
79
+ async value(...props) {
80
+ let cacheFlag = true;
81
+ const store = await GetCacheStore(this.app).catch(() => {
82
+ cacheFlag = false;
83
+ DefaultLogger.Error("Get cache store instance failed.");
84
+ return null;
85
+ });
86
+ if (cacheFlag) {
87
+ // tslint:disable-next-line: one-variable-per-declaration
88
+ let key = "", res;
89
+ if (props && props.length > 0) {
90
+ key = `${identifier}:${methodName}:${helper.murmurHash(JSON.stringify(props))}`;
91
+ }
92
+ else {
93
+ key = `${identifier}:${methodName}`;
94
+ }
95
+ res = await store.hget(cacheName, key).catch(() => null);
96
+ if (!helper.isEmpty(res)) {
97
+ return JSON.parse(res);
98
+ }
99
+ // tslint:disable-next-line: no-invalid-this
100
+ res = await value.apply(this, props);
101
+ // prevent cache penetration
102
+ if (helper.isEmpty(res)) {
103
+ res = "";
104
+ timeout = 60;
105
+ }
106
+ // async set store
107
+ store.hset(cacheName, key, JSON.stringify(res), timeout).catch(() => null);
108
+ return res;
109
+ }
110
+ else {
111
+ // tslint:disable-next-line: no-invalid-this
112
+ return value.apply(this, props);
113
+ }
114
+ }
115
+ };
116
+ // bind app_ready hook event
117
+ InitCacheStore();
118
+ return descriptor;
119
+ };
120
+ }
121
+ /**
122
+ * Decorating the execution of this method will trigger a cache clear operation. Redis server config from db.ts.
123
+ *
124
+ * @export
125
+ * @param {string} cacheName cacheName cache name
126
+ * @param {eventTimes} [eventTime="Before"]
127
+ * @returns
128
+ */
129
+ function CacheEvict(cacheName, eventTime = "Before") {
130
+ return (target, methodName, descriptor) => {
131
+ const componentType = IOCContainer.getType(target);
132
+ if (componentType !== "SERVICE" && componentType !== "COMPONENT") {
133
+ throw Error("This decorator only used in the service、component class.");
134
+ }
135
+ IOCContainer.getIdentifier(target);
136
+ const { value, configurable, enumerable } = descriptor;
137
+ descriptor = {
138
+ configurable,
139
+ enumerable,
140
+ writable: true,
141
+ async value(...props) {
142
+ let cacheFlag = true;
143
+ const store = await GetCacheStore(this.app).catch(() => {
144
+ cacheFlag = false;
145
+ DefaultLogger.Error("Get cache store instance failed.");
146
+ return null;
147
+ });
148
+ if (cacheFlag) {
149
+ if (eventTime === "Before") {
150
+ await store.del(cacheName).catch(() => null);
151
+ // tslint:disable-next-line: no-invalid-this
152
+ return value.apply(this, props);
153
+ }
154
+ else {
155
+ // tslint:disable-next-line: no-invalid-this
156
+ const res = await value.apply(this, props);
157
+ store.del(cacheName).catch(() => null);
158
+ return res;
159
+ }
160
+ }
161
+ else {
162
+ // tslint:disable-next-line: no-invalid-this
163
+ return value.apply(this, props);
164
+ }
165
+ }
166
+ };
167
+ // bind app_ready hook event
168
+ InitCacheStore();
169
+ return descriptor;
170
+ };
171
+ }
172
+
173
+ export { CacheAble, CacheEvict, GetCacheStore };
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "koatty_cacheable",
3
+ "version": "1.3.8",
4
+ "description": "Cacheable for koatty.",
5
+ "scripts": {
6
+ "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
7
+ "build:cp": "node scripts/postBuild && copyfiles package.json LICENSE README.md dist/",
8
+ "build:js": "del-cli --force dist && npx rollup --bundleConfigAsCjs -c .rollup.config.js",
9
+ "build:doc": "del-cli --force docs/api && npx api-documenter markdown --input temp --output docs/api",
10
+ "build:dts": "del-cli --force temp && npx tsc && npx api-extractor run --local --verbose",
11
+ "eslint": "eslint --ext .ts,.js ./",
12
+ "prepublishOnly": "npm test && npm run build",
13
+ "prerelease": "npm test && npm run build",
14
+ "pub": "git push --follow-tags origin && npm publish",
15
+ "release": "standard-version",
16
+ "test": "npm run eslint && jest --passWithNoTests"
17
+ },
18
+ "main": "./dist/index.js",
19
+ "exports": {
20
+ "require": "./dist/index.js",
21
+ "import": "./dist/index.mjs"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/thinkkoa/koatty_cacheable.git"
26
+ },
27
+ "keywords": [
28
+ "cache",
29
+ "store",
30
+ "koatty",
31
+ "thinkkoa"
32
+ ],
33
+ "engines": {
34
+ "node": ">10.0.0"
35
+ },
36
+ "author": {
37
+ "name": "richenlin",
38
+ "email": "richenlin@gmail.com"
39
+ },
40
+ "license": "BSD-3-Clause",
41
+ "bugs": {
42
+ "url": "https://github.com/thinkkoa/koatty_cacheable/issues"
43
+ },
44
+ "homepage": "https://github.com/thinkkoa/koatty_cacheable",
45
+ "maintainers": [
46
+ {
47
+ "name": "richenlin",
48
+ "email": "richenlin@gmail.com"
49
+ }
50
+ ],
51
+ "devDependencies": {
52
+ "@commitlint/cli": "^17.x.x",
53
+ "@commitlint/config-conventional": "^17.x.x",
54
+ "@microsoft/api-documenter": "^7.x.x",
55
+ "@microsoft/api-extractor": "^7.x.x",
56
+ "@rollup/plugin-json": "^6.x.x",
57
+ "@types/jest": "^29.x.x",
58
+ "@types/koa": "^2.x.x",
59
+ "@types/node": "^18.x.x",
60
+ "@typescript-eslint/eslint-plugin": "^5.x.x",
61
+ "@typescript-eslint/parser": "^5.x.x",
62
+ "conventional-changelog-cli": "^2.x.x",
63
+ "copyfiles": "^2.x.x",
64
+ "del-cli": "^4.x.x",
65
+ "eslint": "^8.x.x",
66
+ "eslint-plugin-jest": "^27.x.x",
67
+ "husky": "^4.x.x",
68
+ "jest": "^29.x.x",
69
+ "jest-html-reporters": "^3.x.x",
70
+ "rollup": "^3.x.x",
71
+ "rollup-plugin-typescript2": "^0.x.x",
72
+ "standard-version": "^9.x.x",
73
+ "ts-jest": "^29.x.x",
74
+ "ts-node": "^10.x.x",
75
+ "typescript": "^4.x.x"
76
+ },
77
+ "dependencies": {
78
+ "koatty_container": "^1.x.x",
79
+ "koatty_lib": "^1.x.x",
80
+ "koatty_logger": "^2.x.x",
81
+ "koatty_store": "^1.x.x",
82
+ "tslib": "^2.4.1"
83
+ },
84
+ "peerDependencies": {
85
+ "koatty_container": "^1.x.x",
86
+ "koatty_lib": "^1.x.x",
87
+ "koatty_logger": "^2.x.x",
88
+ "koatty_store": "^1.x.x"
89
+ }
90
+ }
package/package.json CHANGED
@@ -1,18 +1,25 @@
1
1
  {
2
2
  "name": "koatty_cacheable",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "description": "Cacheable for koatty.",
5
5
  "scripts": {
6
- "build": "del-cli --force dist && tsc",
6
+ "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
7
+ "build:cp": "node scripts/postBuild && copyfiles package.json LICENSE README.md dist/",
8
+ "build:js": "del-cli --force dist && npx rollup --bundleConfigAsCjs -c .rollup.config.js",
9
+ "build:doc": "del-cli --force docs/api && npx api-documenter markdown --input temp --output docs/api",
10
+ "build:dts": "del-cli --force temp && npx tsc && npx api-extractor run --local --verbose",
7
11
  "eslint": "eslint --ext .ts,.js ./",
8
12
  "prepublishOnly": "npm test && npm run build",
9
- "release": "npm run prepublishOnly && standard-version",
13
+ "prerelease": "npm test && npm run build",
10
14
  "pub": "git push --follow-tags origin && npm publish",
11
- "test": "npm run eslint && jest --passWithNoTests",
12
- "test:cov": "jest --collectCoverage --detectOpenHandles",
13
- "version": "conventional-changelog -p angular -i CHANGELOG.md -s"
15
+ "release": "standard-version",
16
+ "test": "npm run eslint && jest --passWithNoTests"
14
17
  },
15
18
  "main": "./dist/index.js",
19
+ "exports": {
20
+ "require": "./dist/index.js",
21
+ "import": "./dist/index.mjs"
22
+ },
16
23
  "repository": {
17
24
  "type": "git",
18
25
  "url": "git+https://github.com/thinkkoa/koatty_cacheable.git"
@@ -42,39 +49,42 @@
42
49
  }
43
50
  ],
44
51
  "devDependencies": {
45
- "@babel/core": "^7.x.x",
46
- "@babel/plugin-proposal-decorators": "^7.x.x",
47
- "@babel/preset-env": "^7.x.x",
48
- "@babel/preset-typescript": "^7.x.x",
49
- "@commitlint/cli": "^12.x.x",
50
- "@commitlint/config-conventional": "^15.x.x",
51
- "@types/jest": "^27.x.x",
52
+ "@commitlint/cli": "^17.x.x",
53
+ "@commitlint/config-conventional": "^17.x.x",
54
+ "@microsoft/api-documenter": "^7.x.x",
55
+ "@microsoft/api-extractor": "^7.x.x",
56
+ "@rollup/plugin-json": "^6.x.x",
57
+ "@types/jest": "^29.x.x",
52
58
  "@types/koa": "^2.x.x",
53
- "@types/node": "^16.x.x",
59
+ "@types/node": "^18.x.x",
54
60
  "@typescript-eslint/eslint-plugin": "^5.x.x",
55
61
  "@typescript-eslint/parser": "^5.x.x",
56
62
  "conventional-changelog-cli": "^2.x.x",
63
+ "copyfiles": "^2.x.x",
57
64
  "del-cli": "^4.x.x",
58
65
  "eslint": "^8.x.x",
59
- "eslint-plugin-jest": "^25.x.x",
60
- "husky": "^7.x.x",
61
- "jest": "^27.x.x",
62
- "jest-html-reporters": "^2.x.x",
66
+ "eslint-plugin-jest": "^27.x.x",
67
+ "husky": "^4.x.x",
68
+ "jest": "^29.x.x",
69
+ "jest-html-reporters": "^3.x.x",
70
+ "rollup": "^3.x.x",
71
+ "rollup-plugin-typescript2": "^0.x.x",
63
72
  "standard-version": "^9.x.x",
64
- "ts-jest": "^27.x.x",
73
+ "ts-jest": "^29.x.x",
65
74
  "ts-node": "^10.x.x",
66
75
  "typescript": "^4.x.x"
67
76
  },
68
77
  "dependencies": {
69
78
  "koatty_container": "^1.x.x",
70
79
  "koatty_lib": "^1.x.x",
71
- "koatty_logger": "^1.x.x",
80
+ "koatty_logger": "^2.x.x",
72
81
  "koatty_store": "^1.x.x",
73
- "tslib": "^2.3.1"
82
+ "tslib": "^2.4.1"
74
83
  },
75
- "husky": {
76
- "hooks": {
77
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
78
- }
84
+ "peerDependencies": {
85
+ "koatty_container": "^1.x.x",
86
+ "koatty_lib": "^1.x.x",
87
+ "koatty_logger": "^2.x.x",
88
+ "koatty_store": "^1.x.x"
79
89
  }
80
90
  }
package/.eslintignore DELETED
@@ -1,9 +0,0 @@
1
- node_modules
2
- .eslintrc.js
3
- **/package-lock.json
4
- **/yarn.lock
5
- **/*.config.js
6
- dist
7
- coverage
8
- test
9
- demo
package/.eslintrc.js DELETED
@@ -1,43 +0,0 @@
1
- /**
2
- *
3
- */
4
- module.exports = {
5
- root: true,
6
- parser: '@typescript-eslint/parser',
7
- extends: [
8
- 'plugin:@typescript-eslint/recommended', // 使用@typescript-eslint/eslint-plugin的推荐规则
9
- 'plugin:jest/recommended',
10
- ],
11
- plugins: [
12
- '@typescript-eslint',
13
- 'jest',
14
- ],
15
- parserOptions: {
16
- project: './tsconfig.json',
17
- },
18
- env: {
19
- node: true,
20
- mongo: true,
21
- jest: true,
22
- },
23
- rules: {
24
- "@typescript-eslint/no-explicit-any": "off",
25
- // "@typescript-eslint/no-require-imports": "off",
26
- "@typescript-eslint/no-var-requires": "off",
27
- "@typescript-eslint/member-ordering": "off",
28
- "@typescript-eslint/consistent-type-assertions": "off",
29
- "@typescript-eslint/no-param-reassign": "off",
30
- "@typescript-eslint/no-empty-function": "off",
31
- "@typescript-eslint/no-empty-interface": "off",
32
- "@typescript-eslint/explicit-module-boundary-types": "off",
33
- "@typescript-eslint/ban-types": ["error",
34
- {
35
- "types": {
36
- "Object": false,
37
- "Function": false,
38
- },
39
- "extendDefaults": true
40
- }
41
- ],
42
- },
43
- };
package/babel.config.js DELETED
@@ -1,21 +0,0 @@
1
- /*
2
- * @Description : babel配置
3
- * @usage : 用于jest执行用例
4
- */
5
-
6
- module.exports = {
7
- presets: [
8
- [
9
- '@babel/preset-env',
10
- {
11
- targets: {
12
- node: 'current',
13
- },
14
- },
15
- ],
16
- '@babel/preset-typescript',
17
- ],
18
- plugins: [
19
- ['@babel/plugin-proposal-decorators', { 'legacy': true }]
20
- ],
21
- };
@@ -1,14 +0,0 @@
1
- /*
2
- *
3
- */
4
- module.exports = {
5
- extends: ['@commitlint/config-conventional'],
6
- rules: {
7
- 'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore']],
8
- 'type-empty': [2, 'never'],
9
- 'scope-enum': [0], // 不校验scope类型
10
- 'scope-empty': [0], // 不校验scope是否设置
11
- 'subject-case': [0], // 不校验描述的字符格式
12
- 'subject-min-length': [2, 'always', 5], // 描述至少5个字符
13
- },
14
- };
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA;;;;;;GAMG;AACH,gEAAqC;AACrC,iDAAwD;AACxD,+CAA+D;AAC/D,uDAA6D;AAW7D,aAAa;AACb,MAAM,UAAU,GAAwB;IACpC,KAAK,EAAE,IAAI;CACd,CAAC;AAEF;;;;;;GAMG;AACI,KAAK,UAAU,aAAa,CAAC,GAAgB;;IAChD,IAAI,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC,aAAa,EAAE;QACpD,OAAO,UAAU,CAAC,KAAK,CAAC;KAC3B;IACD,MAAM,GAAG,GAAiB,MAAA,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,mCAAI,EAAE,CAAC;IAC/D,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACrB,6BAAM,CAAC,IAAI,CAAC,8HAA8H,CAAC,CAAC;KAC/I;IACD,UAAU,CAAC,KAAK,GAAG,oBAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC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CAAC;wBAClD,4CAA4C;wBAC5C,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;qBACnC;yBAAM;wBACH,4CAA4C;wBAC5C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;wBAC3C,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;wBAC5C,OAAO,GAAG,CAAC;qBACd;iBACJ;qBAAM;oBACH,4CAA4C;oBAC5C,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;iBACnC;YACL,CAAC;SACJ,CAAC;QACF,6BAA6B;QAC7B,cAAc,EAAE,CAAC;QACjB,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC;AAzCD,gCAyCC"}
package/jest.config.js DELETED
@@ -1,36 +0,0 @@
1
- /**
2
- *
3
- */
4
-
5
- // jest详细配置参见:
6
- // https://jestjs.io/docs/en/configuration.html
7
-
8
- module.exports = {
9
- preset: 'ts-jest',
10
- testEnvironment: 'node', // 测试用例运行环境
11
- testMatch: ['<rootDir>/test/**/*.(spec|test).[jt]s'], // 匹配测试用例的路径规则
12
- reporters: [
13
- 'default',
14
- 'jest-html-reporters'
15
- ], // 测试用例报告
16
- collectCoverage: true, // 是否收集测试时的覆盖率信息
17
- coverageReporters: [
18
- 'html',
19
- 'lcov',
20
- 'json',
21
- 'text',
22
- 'clover',
23
- 'text-summary',
24
- ], // 收集测试时的覆盖率信息
25
- // 将 `ts-jest` 的配置注入到运行时的全局变量中
26
- globals: {
27
- 'ts-jest': {
28
- // 是否使用 babel 配置来转译
29
- babelConfig: true,
30
- // 编译 Typescript 所依赖的配置
31
- tsconfig: '<rootDir>/tsconfig.json',
32
- // 是否启用报告诊断,这里是不启用
33
- diagnostics: false,
34
- },
35
- }
36
- };