koatty_store 1.4.10 → 1.5.5
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/.rollup.config.js +63 -0
- package/.vscode/launch.json +25 -0
- package/CHANGELOG.md +6 -0
- package/dist/LICENSE +29 -0
- package/dist/README.md +2 -0
- package/dist/index.d.ts +866 -57
- package/dist/index.js +1913 -57
- package/dist/index.mjs +1886 -0
- package/dist/package.json +92 -0
- package/package.json +30 -24
- package/.eslintignore +0 -9
- package/.eslintrc.js +0 -43
- package/babel.config.js +0 -21
- package/commitlint.config.js +0 -14
- package/dist/index.js.map +0 -1
- package/dist/memory.d.ts +0 -86
- package/dist/memory.js +0 -140
- package/dist/memory.js.map +0 -1
- package/dist/redis.d.ts +0 -321
- package/dist/redis.js +0 -545
- package/dist/redis.js.map +0 -1
- package/jest.config.js +0 -36
- package/jest_html_reporters.html +0 -60
- package/tsconfig.json +0 -67
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "koatty_store",
|
|
3
|
+
"version": "1.5.5",
|
|
4
|
+
"description": "Cache store 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 -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
|
+
"release": "standard-version",
|
|
15
|
+
"test": "npm run eslint && jest --passWithNoTests"
|
|
16
|
+
},
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"exports": {
|
|
19
|
+
"require": "./dist/index.js",
|
|
20
|
+
"import": "./dist/index.mjs"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/koatty/koatty_store.git"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"web",
|
|
28
|
+
"typescript",
|
|
29
|
+
"framework",
|
|
30
|
+
"mvc",
|
|
31
|
+
"koa2",
|
|
32
|
+
"restful",
|
|
33
|
+
"agile",
|
|
34
|
+
"koatty_store",
|
|
35
|
+
"koatty"
|
|
36
|
+
],
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">10.0.0"
|
|
39
|
+
},
|
|
40
|
+
"author": {
|
|
41
|
+
"name": "richenlin",
|
|
42
|
+
"email": "richenlin@gmail.com"
|
|
43
|
+
},
|
|
44
|
+
"license": "BSD-3-Clause",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/koatty/koatty_store/issues"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://github.com/koatty/koatty_store",
|
|
49
|
+
"maintainers": [
|
|
50
|
+
{
|
|
51
|
+
"name": "richenlin",
|
|
52
|
+
"email": "richenlin@gmail.com"
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@commitlint/cli": "^17.x.x",
|
|
57
|
+
"@commitlint/config-conventional": "^17.x.x",
|
|
58
|
+
"@microsoft/api-documenter": "^7.x.x",
|
|
59
|
+
"@microsoft/api-extractor": "^7.x.x",
|
|
60
|
+
"@rollup/plugin-json": "^4.x.x",
|
|
61
|
+
"@types/jest": "^27.x.x",
|
|
62
|
+
"@types/koa": "^2.x.x",
|
|
63
|
+
"@types/node": "^16.x.x",
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^5.x.x",
|
|
65
|
+
"@typescript-eslint/parser": "^5.x.x",
|
|
66
|
+
"conventional-changelog-cli": "^2.x.x",
|
|
67
|
+
"copyfiles": "^2.x.x",
|
|
68
|
+
"del-cli": "^4.x.x",
|
|
69
|
+
"eslint": "^8.x.x",
|
|
70
|
+
"eslint-plugin-jest": "^26.x.x",
|
|
71
|
+
"husky": "^4.x.x",
|
|
72
|
+
"jest": "^28.x.x",
|
|
73
|
+
"jest-html-reporters": "^3.x.x",
|
|
74
|
+
"rollup": "^2.x.x",
|
|
75
|
+
"rollup-plugin-typescript2": "^0.x.x",
|
|
76
|
+
"standard-version": "^9.x.x",
|
|
77
|
+
"ts-jest": "^28.x.x",
|
|
78
|
+
"ts-node": "^10.x.x",
|
|
79
|
+
"typescript": "^4.x.x"
|
|
80
|
+
},
|
|
81
|
+
"dependencies": {
|
|
82
|
+
"@types/ioredis": "^4.x.x",
|
|
83
|
+
"generic-pool": "^3.8.2",
|
|
84
|
+
"ioredis": "^4.28.5",
|
|
85
|
+
"koatty_lib": "^1.x.x",
|
|
86
|
+
"koatty_logger": "^1.x.x"
|
|
87
|
+
},
|
|
88
|
+
"peerDependencies": {
|
|
89
|
+
"koatty_lib": "^1.x.x",
|
|
90
|
+
"koatty_logger": "^1.x.x"
|
|
91
|
+
}
|
|
92
|
+
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koatty_store",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.5",
|
|
4
4
|
"description": "Cache store for koatty.",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "
|
|
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 -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
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"test": "npm run eslint && jest --passWithNoTests"
|
|
12
|
-
"test:cov": "jest --collectCoverage --detectOpenHandles",
|
|
13
|
-
"version": "conventional-changelog -p angular -i CHANGELOG.md -s"
|
|
13
|
+
"prerelease": "npm test && npm run build",
|
|
14
|
+
"release": "standard-version",
|
|
15
|
+
"test": "npm run eslint && jest --passWithNoTests"
|
|
14
16
|
},
|
|
15
17
|
"main": "./dist/index.js",
|
|
18
|
+
"exports": {
|
|
19
|
+
"require": "./dist/index.js",
|
|
20
|
+
"import": "./dist/index.mjs"
|
|
21
|
+
},
|
|
16
22
|
"repository": {
|
|
17
23
|
"type": "git",
|
|
18
24
|
"url": "git+https://github.com/koatty/koatty_store.git"
|
|
@@ -47,40 +53,40 @@
|
|
|
47
53
|
}
|
|
48
54
|
],
|
|
49
55
|
"devDependencies": {
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
54
|
-
"@
|
|
55
|
-
"@commitlint/config-conventional": "^15.x.x",
|
|
56
|
+
"@commitlint/cli": "^17.x.x",
|
|
57
|
+
"@commitlint/config-conventional": "^17.x.x",
|
|
58
|
+
"@microsoft/api-documenter": "^7.x.x",
|
|
59
|
+
"@microsoft/api-extractor": "^7.x.x",
|
|
60
|
+
"@rollup/plugin-json": "^4.x.x",
|
|
56
61
|
"@types/jest": "^27.x.x",
|
|
57
62
|
"@types/koa": "^2.x.x",
|
|
58
63
|
"@types/node": "^16.x.x",
|
|
59
64
|
"@typescript-eslint/eslint-plugin": "^5.x.x",
|
|
60
65
|
"@typescript-eslint/parser": "^5.x.x",
|
|
61
66
|
"conventional-changelog-cli": "^2.x.x",
|
|
67
|
+
"copyfiles": "^2.x.x",
|
|
62
68
|
"del-cli": "^4.x.x",
|
|
63
69
|
"eslint": "^8.x.x",
|
|
64
|
-
"eslint-plugin-jest": "^
|
|
65
|
-
"husky": "^
|
|
66
|
-
"jest": "^
|
|
67
|
-
"jest-html-reporters": "^
|
|
70
|
+
"eslint-plugin-jest": "^26.x.x",
|
|
71
|
+
"husky": "^4.x.x",
|
|
72
|
+
"jest": "^28.x.x",
|
|
73
|
+
"jest-html-reporters": "^3.x.x",
|
|
74
|
+
"rollup": "^2.x.x",
|
|
75
|
+
"rollup-plugin-typescript2": "^0.x.x",
|
|
68
76
|
"standard-version": "^9.x.x",
|
|
69
|
-
"ts-jest": "^
|
|
77
|
+
"ts-jest": "^28.x.x",
|
|
70
78
|
"ts-node": "^10.x.x",
|
|
71
79
|
"typescript": "^4.x.x"
|
|
72
80
|
},
|
|
73
81
|
"dependencies": {
|
|
74
82
|
"@types/ioredis": "^4.x.x",
|
|
75
|
-
"@outofsync/memory-cache": "^1.4.1",
|
|
76
83
|
"generic-pool": "^3.8.2",
|
|
77
|
-
"ioredis": "^4.28.
|
|
84
|
+
"ioredis": "^4.28.5",
|
|
78
85
|
"koatty_lib": "^1.x.x",
|
|
79
86
|
"koatty_logger": "^1.x.x"
|
|
80
87
|
},
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
}
|
|
88
|
+
"peerDependencies": {
|
|
89
|
+
"koatty_lib": "^1.x.x",
|
|
90
|
+
"koatty_logger": "^1.x.x"
|
|
85
91
|
}
|
|
86
92
|
}
|
package/.eslintignore
DELETED
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
|
-
};
|
package/commitlint.config.js
DELETED
|
@@ -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;;;;;;;GAOG;AACH,qCAAuC;AACvC,mCAAqC;AACrC,iCAAwD;AAA/C,mGAAA,UAAU,OAAA;AACnB,mCAA2D;AAAlD,qGAAA,WAAW,OAAA;AA0CpB;;;;;GAKG;AACH,MAAa,KAAK;IAGd;;;;;;OAMG;IACH,MAAM,CAAC,WAAW,CAAC,OAAqB;QACpC,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,OAAO,IAAI,CAAC,QAAQ,CAAC;SACxB;QACD,OAAO,GAAG;YACN,GAAG;gBACC,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,IAAI;gBACV,UAAU,EAAE,QAAQ;gBACpB,OAAO,EAAE,KAAK;gBACd,SAAS,EAAE,EAAE;gBACb,YAAY,EAAE,GAAG;aACpB,EAAE,GAAG,OAAO;SAChB,CAAC;QACF,QAAQ,OAAO,CAAC,IAAI,EAAE;YAClB,KAAK,OAAO;gBACR,IAAI,CAAC,QAAQ,GAAG,IAAI,kBAAU,CAAC,OAAO,CAAC,CAAC;gBACxC,MAAM;YACV,KAAK,QAAQ,CAAC;YACd;gBACI,IAAI,CAAC,QAAQ,GAAG,IAAI,oBAAW,CAAC,OAAO,CAAC,CAAC;gBACzC,MAAM;SACb;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CAGJ;AAvCD,sBAuCC"}
|
package/dist/memory.d.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { CacheStore, StoreOptions } from ".";
|
|
2
|
-
/**
|
|
3
|
-
* MemoryStore Options
|
|
4
|
-
*
|
|
5
|
-
* @export
|
|
6
|
-
* @interface MemoryStoreOptions
|
|
7
|
-
*/
|
|
8
|
-
export interface MemoryStoreOptions {
|
|
9
|
-
timeout?: number;
|
|
10
|
-
}
|
|
11
|
-
export declare class MemoryStore implements CacheStore {
|
|
12
|
-
client: any;
|
|
13
|
-
private options;
|
|
14
|
-
private pool;
|
|
15
|
-
/**
|
|
16
|
-
* Creates an instance of MemoryStore.
|
|
17
|
-
* @param {StoreOptions} options
|
|
18
|
-
* @memberof MemoryStore
|
|
19
|
-
*/
|
|
20
|
-
constructor(options: StoreOptions);
|
|
21
|
-
/**
|
|
22
|
-
* getConnection
|
|
23
|
-
*
|
|
24
|
-
* @returns {*}
|
|
25
|
-
* @memberof MemoryStore
|
|
26
|
-
*/
|
|
27
|
-
getConnection(): any;
|
|
28
|
-
/**
|
|
29
|
-
* close
|
|
30
|
-
*
|
|
31
|
-
* @returns {*} {Promise<void>}
|
|
32
|
-
* @memberof MemoryStore
|
|
33
|
-
*/
|
|
34
|
-
close(): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* release
|
|
37
|
-
*
|
|
38
|
-
* @param {*} conn
|
|
39
|
-
* @returns {*} {Promise<void>}
|
|
40
|
-
* @memberof MemoryStore
|
|
41
|
-
*/
|
|
42
|
-
release(conn: any): Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* defineCommand
|
|
45
|
-
*
|
|
46
|
-
* @param {string} name
|
|
47
|
-
* @param {*} scripts
|
|
48
|
-
* @memberof MemoryStore
|
|
49
|
-
*/
|
|
50
|
-
defineCommand(name: string, scripts: any): Promise<any>;
|
|
51
|
-
/**
|
|
52
|
-
* get and compare value
|
|
53
|
-
*
|
|
54
|
-
* @param {string} name
|
|
55
|
-
* @param {(string | number)} value
|
|
56
|
-
* @returns {*} {Promise<any>}
|
|
57
|
-
* @memberof MemoryStore
|
|
58
|
-
*/
|
|
59
|
-
getCompare(name: string, value: string | number): Promise<any>;
|
|
60
|
-
/**
|
|
61
|
-
* get
|
|
62
|
-
*
|
|
63
|
-
* @param {string} name
|
|
64
|
-
* @returns {*} {Promise<any>}
|
|
65
|
-
* @memberof MemoryStore
|
|
66
|
-
*/
|
|
67
|
-
get(name: string): Promise<any>;
|
|
68
|
-
/**
|
|
69
|
-
* set
|
|
70
|
-
*
|
|
71
|
-
* @param {string} name
|
|
72
|
-
* @param {(string | number)} value
|
|
73
|
-
* @param {number} [timeout]
|
|
74
|
-
* @returns {*} {Promise<any>}
|
|
75
|
-
* @memberof MemoryStore
|
|
76
|
-
*/
|
|
77
|
-
set(name: string, value: string | number, timeout?: number): Promise<any>;
|
|
78
|
-
/**
|
|
79
|
-
* del
|
|
80
|
-
*
|
|
81
|
-
* @param {string} name
|
|
82
|
-
* @returns {*}
|
|
83
|
-
* @memberof MemoryStore
|
|
84
|
-
*/
|
|
85
|
-
del(name: string): any;
|
|
86
|
-
}
|
package/dist/memory.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MemoryStore = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const helper = (0, tslib_1.__importStar)(require("koatty_lib"));
|
|
6
|
-
const MemoryCache = require('@outofsync/memory-cache');
|
|
7
|
-
/*
|
|
8
|
-
* @Description:
|
|
9
|
-
* @Usage:
|
|
10
|
-
* @Author: richen
|
|
11
|
-
* @Date: 2021-06-29 19:07:57
|
|
12
|
-
* @LastEditTime: 2021-06-29 19:45:25
|
|
13
|
-
*/
|
|
14
|
-
class MemoryStore {
|
|
15
|
-
/**
|
|
16
|
-
* Creates an instance of MemoryStore.
|
|
17
|
-
* @param {StoreOptions} options
|
|
18
|
-
* @memberof MemoryStore
|
|
19
|
-
*/
|
|
20
|
-
constructor(options) {
|
|
21
|
-
this.options = options;
|
|
22
|
-
this.client = null;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* getConnection
|
|
26
|
-
*
|
|
27
|
-
* @returns {*}
|
|
28
|
-
* @memberof MemoryStore
|
|
29
|
-
*/
|
|
30
|
-
getConnection() {
|
|
31
|
-
if (!this.pool) {
|
|
32
|
-
this.pool = new MemoryCache({ bypassUnsupported: true });
|
|
33
|
-
}
|
|
34
|
-
if (!this.client) {
|
|
35
|
-
this.client = this.pool.createClient();
|
|
36
|
-
this.client.status = "ready";
|
|
37
|
-
}
|
|
38
|
-
return this.client;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* close
|
|
42
|
-
*
|
|
43
|
-
* @returns {*} {Promise<void>}
|
|
44
|
-
* @memberof MemoryStore
|
|
45
|
-
*/
|
|
46
|
-
async close() {
|
|
47
|
-
this.client.end();
|
|
48
|
-
this.client = null;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* release
|
|
52
|
-
*
|
|
53
|
-
* @param {*} conn
|
|
54
|
-
* @returns {*} {Promise<void>}
|
|
55
|
-
* @memberof MemoryStore
|
|
56
|
-
*/
|
|
57
|
-
async release(conn) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* defineCommand
|
|
62
|
-
*
|
|
63
|
-
* @param {string} name
|
|
64
|
-
* @param {*} scripts
|
|
65
|
-
* @memberof MemoryStore
|
|
66
|
-
*/
|
|
67
|
-
async defineCommand(name, scripts) {
|
|
68
|
-
const client = this.getConnection();
|
|
69
|
-
Object.defineProperty(client, name, {
|
|
70
|
-
value: async function () {
|
|
71
|
-
return scripts;
|
|
72
|
-
},
|
|
73
|
-
writable: false,
|
|
74
|
-
configurable: false,
|
|
75
|
-
enumerable: true,
|
|
76
|
-
});
|
|
77
|
-
return client;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* get and compare value
|
|
81
|
-
*
|
|
82
|
-
* @param {string} name
|
|
83
|
-
* @param {(string | number)} value
|
|
84
|
-
* @returns {*} {Promise<any>}
|
|
85
|
-
* @memberof MemoryStore
|
|
86
|
-
*/
|
|
87
|
-
async getCompare(name, value) {
|
|
88
|
-
const client = this.getConnection();
|
|
89
|
-
const val = client.get(name);
|
|
90
|
-
if (!val) {
|
|
91
|
-
return 0;
|
|
92
|
-
}
|
|
93
|
-
else if (val == value) {
|
|
94
|
-
return client.del(name);
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
return -1;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* get
|
|
102
|
-
*
|
|
103
|
-
* @param {string} name
|
|
104
|
-
* @returns {*} {Promise<any>}
|
|
105
|
-
* @memberof MemoryStore
|
|
106
|
-
*/
|
|
107
|
-
get(name) {
|
|
108
|
-
const client = this.getConnection();
|
|
109
|
-
return client.getAsync(name);
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* set
|
|
113
|
-
*
|
|
114
|
-
* @param {string} name
|
|
115
|
-
* @param {(string | number)} value
|
|
116
|
-
* @param {number} [timeout]
|
|
117
|
-
* @returns {*} {Promise<any>}
|
|
118
|
-
* @memberof MemoryStore
|
|
119
|
-
*/
|
|
120
|
-
set(name, value, timeout) {
|
|
121
|
-
const client = this.getConnection();
|
|
122
|
-
if (helper.isTrueEmpty(timeout)) {
|
|
123
|
-
timeout = this.options.timeout;
|
|
124
|
-
}
|
|
125
|
-
return client.setAsync(name, value, "ex", timeout);
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* del
|
|
129
|
-
*
|
|
130
|
-
* @param {string} name
|
|
131
|
-
* @returns {*}
|
|
132
|
-
* @memberof MemoryStore
|
|
133
|
-
*/
|
|
134
|
-
del(name) {
|
|
135
|
-
const client = this.getConnection();
|
|
136
|
-
return client.delAsync(name);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
exports.MemoryStore = MemoryStore;
|
|
140
|
-
//# sourceMappingURL=memory.js.map
|
package/dist/memory.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":";;;;AAAA,gEAAqC;AAErC,MAAM,WAAW,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAYvD;;;;;;GAMG;AACH,MAAa,WAAW;IAKpB;;;;OAIG;IACH,YAAY,OAAqB;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,aAAa;QACT,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACZ,IAAI,CAAC,IAAI,GAAG,IAAI,WAAW,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;SAC5D;QACD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACd,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC;SAChC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,KAAK;QACP,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAA;QACjB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IACD;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,CAAC,IAAS;QACnB,OAAO;IACX,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,aAAa,CAAC,IAAY,EAAE,OAAY;QAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACpC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE;YAChC,KAAK,EAAE,KAAK;gBACR,OAAO,OAAO,CAAC;YACnB,CAAC;YACD,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,IAAI;SACnB,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,UAAU,CAAC,IAAY,EAAE,KAAsB;QACjD,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACpC,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,GAAG,EAAE;YACN,OAAO,CAAC,CAAC;SACZ;aAAM,IAAI,GAAG,IAAI,KAAK,EAAE;YACrB,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;SAC3B;aAAM;YACH,OAAO,CAAC,CAAC,CAAC;SACb;IACL,CAAC;IAED;;;;;;OAMG;IACH,GAAG,CAAC,IAAY;QACZ,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACpC,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;;OAQG;IACH,GAAG,CAAC,IAAY,EAAE,KAAsB,EAAE,OAAgB;QACtD,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACpC,IAAI,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE;YAC7B,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;SAClC;QACD,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IAED;;;;;;OAMG;IACH,GAAG,CAAC,IAAY;QACZ,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACpC,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;CAEJ;AAvID,kCAuIC"}
|