koatty_cacheable 1.5.0 → 1.6.0
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 +59 -62
- package/CHANGELOG.md +39 -37
- package/LICENSE +29 -29
- package/README.md +56 -56
- package/dist/LICENSE +29 -29
- package/dist/README.md +56 -56
- package/dist/index.d.ts +2 -2
- package/dist/index.js +259 -246
- package/dist/index.mjs +259 -246
- package/dist/package.json +98 -93
- package/package.json +98 -93
- package/target/npmlist.json +0 -1
package/.rollup.config.js
CHANGED
|
@@ -1,63 +1,60 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Description:
|
|
3
|
-
* @Usage:
|
|
4
|
-
* @Author: richen
|
|
5
|
-
* @Date: 2021-12-17 10:20:44
|
|
6
|
-
* @LastEditTime:
|
|
7
|
-
*/
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
})
|
|
61
|
-
]
|
|
62
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* @Description:
|
|
3
|
+
* @Usage:
|
|
4
|
+
* @Author: richen
|
|
5
|
+
* @Date: 2021-12-17 10:20:44
|
|
6
|
+
* @LastEditTime: 2024-11-04 22:04:45
|
|
7
|
+
*/
|
|
8
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
9
|
+
import json from "@rollup/plugin-json";
|
|
10
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
11
|
+
import { builtinModules } from 'module';
|
|
12
|
+
import del from "rollup-plugin-delete";
|
|
13
|
+
import typescript from 'rollup-plugin-typescript2';
|
|
14
|
+
// import babel from '@rollup/plugin-babel';
|
|
15
|
+
const pkg = require('./package.json');
|
|
16
|
+
|
|
17
|
+
export default [
|
|
18
|
+
{
|
|
19
|
+
input: './src/index.ts',
|
|
20
|
+
output: [
|
|
21
|
+
{
|
|
22
|
+
format: 'cjs',
|
|
23
|
+
file: './dist/index.js',
|
|
24
|
+
banner: require('./scripts/copyright'),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
format: 'es',
|
|
28
|
+
file: './dist/index.mjs',
|
|
29
|
+
banner: require('./scripts/copyright'),
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
plugins: [
|
|
33
|
+
del({ targets: ["dist/*", "temp/*", "docs/api"] }),
|
|
34
|
+
// babel({
|
|
35
|
+
// babelHelpers: "runtime",
|
|
36
|
+
// configFile: './babel.config.js',
|
|
37
|
+
// exclude: 'node_modules/**',
|
|
38
|
+
// }),
|
|
39
|
+
json(),
|
|
40
|
+
resolve({
|
|
41
|
+
preferBuiltins: true, // 优先选择内置模块
|
|
42
|
+
}),
|
|
43
|
+
commonjs(),
|
|
44
|
+
typescript({
|
|
45
|
+
tsconfigOverride: {
|
|
46
|
+
compilerOptions: {
|
|
47
|
+
declaration: false,
|
|
48
|
+
declarationMap: false,
|
|
49
|
+
module: "ESNext"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
],
|
|
54
|
+
external: [
|
|
55
|
+
...builtinModules, // 排除 Node.js 内置模块
|
|
56
|
+
...Object.keys(pkg.dependencies || {}), // 排除 package.json 中的外部依赖
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
|
|
63
60
|
]
|
package/CHANGELOG.md
CHANGED
|
@@ -2,40 +2,42 @@
|
|
|
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.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
### [1.4.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
### [1.3.
|
|
5
|
+
## [1.6.0](https://github.com/thinkkoa/koatty_cacheable/compare/v1.5.0...v1.6.0) (2024-11-07)
|
|
6
|
+
|
|
7
|
+
## [1.5.0](https://github.com/thinkkoa/koatty_cacheable/compare/v1.4.3...v1.5.0) (2024-04-01)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* delayedDoubleDeletion ([532f735](https://github.com/thinkkoa/koatty_cacheable/commit/532f735818fc66fa144023cd24282efe350833ba))
|
|
13
|
+
|
|
14
|
+
### [1.4.3](https://github.com/thinkkoa/koatty_cacheable/compare/v1.4.2...v1.4.3) (2024-01-17)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* 缓存key拼装 ([5d0b924](https://github.com/thinkkoa/koatty_cacheable/commit/5d0b9248064d353046bd7287d3a3ee5229e88c23))
|
|
20
|
+
|
|
21
|
+
### [1.4.2](https://github.com/thinkkoa/koatty_cacheable/compare/v1.4.1...v1.4.2) (2023-12-20)
|
|
22
|
+
|
|
23
|
+
### [1.4.1](https://github.com/thinkkoa/koatty_cacheable/compare/v1.4.0...v1.4.1) (2023-08-04)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* default value ([38f2e57](https://github.com/thinkkoa/koatty_cacheable/commit/38f2e57d52d13482907ca9eac6006d1e841bdadd))
|
|
29
|
+
* 初始化缓存改为appReady执行 ([7e9b1ab](https://github.com/thinkkoa/koatty_cacheable/commit/7e9b1abe6acdbdf1b6ad34efa053cbaca1e7b6d7))
|
|
30
|
+
|
|
31
|
+
## [1.4.0](https://github.com/thinkkoa/koatty_cacheable/compare/v1.3.8...v1.4.0) (2023-02-18)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Bug Fixes
|
|
35
|
+
|
|
36
|
+
* cache subkey ([408e3c7](https://github.com/thinkkoa/koatty_cacheable/commit/408e3c709a4dfff6e7d224a22d26e58854a805ac))
|
|
37
|
+
* 启动时链接 ([e7ec709](https://github.com/thinkkoa/koatty_cacheable/commit/e7ec7094be106e4e48783c9b214b8369e8a18297))
|
|
38
|
+
* 支持引入变量做缓存key ([4ce81aa](https://github.com/thinkkoa/koatty_cacheable/commit/4ce81aaaf9610f4a62ddf43e3c4389dd003c2db8))
|
|
39
|
+
* 获取单例 ([0759972](https://github.com/thinkkoa/koatty_cacheable/commit/0759972adf7e86312f60f0bf77604bddf06ce0de))
|
|
40
|
+
|
|
41
|
+
### [1.3.8](https://github.com/thinkkoa/koatty_cacheable/compare/v1.3.6...v1.3.8) (2023-01-13)
|
|
42
|
+
|
|
43
|
+
### [1.3.7](https://github.com/thinkkoa/koatty_cacheable/compare/v1.3.6...v1.3.7) (2022-05-27)
|
package/LICENSE
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
BSD 3-Clause License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020, Koatty
|
|
4
|
-
All rights reserved.
|
|
5
|
-
|
|
6
|
-
Redistribution and use in source and binary forms, with or without
|
|
7
|
-
modification, are permitted provided that the following conditions are met:
|
|
8
|
-
|
|
9
|
-
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
-
list of conditions and the following disclaimer.
|
|
11
|
-
|
|
12
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
-
this list of conditions and the following disclaimer in the documentation
|
|
14
|
-
and/or other materials provided with the distribution.
|
|
15
|
-
|
|
16
|
-
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
-
contributors may be used to endorse or promote products derived from
|
|
18
|
-
this software without specific prior written permission.
|
|
19
|
-
|
|
20
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020, Koatty
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
# koatty_cacheable
|
|
2
|
-
Cacheable for koatty.
|
|
3
|
-
|
|
4
|
-
Koatty框架的 CacheAble, Cacheable, CacheEvict 支持库
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
# Usage
|
|
8
|
-
|
|
9
|
-
db.ts in koatty project:
|
|
10
|
-
|
|
11
|
-
```js
|
|
12
|
-
export default {
|
|
13
|
-
...
|
|
14
|
-
|
|
15
|
-
"CacheStore": {
|
|
16
|
-
type: "memory", // redis or memory, memory is default
|
|
17
|
-
// key_prefix: "koatty",
|
|
18
|
-
// host: '127.0.0.1',
|
|
19
|
-
// port: 6379,
|
|
20
|
-
// name: "",
|
|
21
|
-
// username: "",
|
|
22
|
-
// password: "",
|
|
23
|
-
// db: 0,
|
|
24
|
-
// timeout: 30,
|
|
25
|
-
// pool_size: 10,
|
|
26
|
-
// conn_timeout: 30
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
...
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
used in service:
|
|
35
|
-
|
|
36
|
-
```js
|
|
37
|
-
import { CacheAble, CacheEvict, GetCacheStore } from "koatty_cacheable";
|
|
38
|
-
|
|
39
|
-
export class TestService {
|
|
40
|
-
|
|
41
|
-
@CacheAble("testCache") // auto cached
|
|
42
|
-
getTest(){
|
|
43
|
-
//todo
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@CacheEvict("testCache") // auto clear cache
|
|
47
|
-
setTest(){
|
|
48
|
-
//todo
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
test(){
|
|
52
|
-
const store = GetCacheStore(this.app);
|
|
53
|
-
store.set(key, value);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
1
|
+
# koatty_cacheable
|
|
2
|
+
Cacheable for koatty.
|
|
3
|
+
|
|
4
|
+
Koatty框架的 CacheAble, Cacheable, CacheEvict 支持库
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# Usage
|
|
8
|
+
|
|
9
|
+
db.ts in koatty project:
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
export default {
|
|
13
|
+
...
|
|
14
|
+
|
|
15
|
+
"CacheStore": {
|
|
16
|
+
type: "memory", // redis or memory, memory is default
|
|
17
|
+
// key_prefix: "koatty",
|
|
18
|
+
// host: '127.0.0.1',
|
|
19
|
+
// port: 6379,
|
|
20
|
+
// name: "",
|
|
21
|
+
// username: "",
|
|
22
|
+
// password: "",
|
|
23
|
+
// db: 0,
|
|
24
|
+
// timeout: 30,
|
|
25
|
+
// pool_size: 10,
|
|
26
|
+
// conn_timeout: 30
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
...
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
used in service:
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
import { CacheAble, CacheEvict, GetCacheStore } from "koatty_cacheable";
|
|
38
|
+
|
|
39
|
+
export class TestService {
|
|
40
|
+
|
|
41
|
+
@CacheAble("testCache") // auto cached
|
|
42
|
+
getTest(){
|
|
43
|
+
//todo
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@CacheEvict("testCache") // auto clear cache
|
|
47
|
+
setTest(){
|
|
48
|
+
//todo
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
test(){
|
|
52
|
+
const store = GetCacheStore(this.app);
|
|
53
|
+
store.set(key, value);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
57
|
```
|
package/dist/LICENSE
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
BSD 3-Clause License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020, Koatty
|
|
4
|
-
All rights reserved.
|
|
5
|
-
|
|
6
|
-
Redistribution and use in source and binary forms, with or without
|
|
7
|
-
modification, are permitted provided that the following conditions are met:
|
|
8
|
-
|
|
9
|
-
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
-
list of conditions and the following disclaimer.
|
|
11
|
-
|
|
12
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
-
this list of conditions and the following disclaimer in the documentation
|
|
14
|
-
and/or other materials provided with the distribution.
|
|
15
|
-
|
|
16
|
-
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
-
contributors may be used to endorse or promote products derived from
|
|
18
|
-
this software without specific prior written permission.
|
|
19
|
-
|
|
20
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020, Koatty
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/dist/README.md
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
# koatty_cacheable
|
|
2
|
-
Cacheable for koatty.
|
|
3
|
-
|
|
4
|
-
Koatty框架的 CacheAble, Cacheable, CacheEvict 支持库
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
# Usage
|
|
8
|
-
|
|
9
|
-
db.ts in koatty project:
|
|
10
|
-
|
|
11
|
-
```js
|
|
12
|
-
export default {
|
|
13
|
-
...
|
|
14
|
-
|
|
15
|
-
"CacheStore": {
|
|
16
|
-
type: "memory", // redis or memory, memory is default
|
|
17
|
-
// key_prefix: "koatty",
|
|
18
|
-
// host: '127.0.0.1',
|
|
19
|
-
// port: 6379,
|
|
20
|
-
// name: "",
|
|
21
|
-
// username: "",
|
|
22
|
-
// password: "",
|
|
23
|
-
// db: 0,
|
|
24
|
-
// timeout: 30,
|
|
25
|
-
// pool_size: 10,
|
|
26
|
-
// conn_timeout: 30
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
...
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
used in service:
|
|
35
|
-
|
|
36
|
-
```js
|
|
37
|
-
import { CacheAble, CacheEvict, GetCacheStore } from "koatty_cacheable";
|
|
38
|
-
|
|
39
|
-
export class TestService {
|
|
40
|
-
|
|
41
|
-
@CacheAble("testCache") // auto cached
|
|
42
|
-
getTest(){
|
|
43
|
-
//todo
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@CacheEvict("testCache") // auto clear cache
|
|
47
|
-
setTest(){
|
|
48
|
-
//todo
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
test(){
|
|
52
|
-
const store = GetCacheStore(this.app);
|
|
53
|
-
store.set(key, value);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
1
|
+
# koatty_cacheable
|
|
2
|
+
Cacheable for koatty.
|
|
3
|
+
|
|
4
|
+
Koatty框架的 CacheAble, Cacheable, CacheEvict 支持库
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# Usage
|
|
8
|
+
|
|
9
|
+
db.ts in koatty project:
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
export default {
|
|
13
|
+
...
|
|
14
|
+
|
|
15
|
+
"CacheStore": {
|
|
16
|
+
type: "memory", // redis or memory, memory is default
|
|
17
|
+
// key_prefix: "koatty",
|
|
18
|
+
// host: '127.0.0.1',
|
|
19
|
+
// port: 6379,
|
|
20
|
+
// name: "",
|
|
21
|
+
// username: "",
|
|
22
|
+
// password: "",
|
|
23
|
+
// db: 0,
|
|
24
|
+
// timeout: 30,
|
|
25
|
+
// pool_size: 10,
|
|
26
|
+
// conn_timeout: 30
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
...
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
used in service:
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
import { CacheAble, CacheEvict, GetCacheStore } from "koatty_cacheable";
|
|
38
|
+
|
|
39
|
+
export class TestService {
|
|
40
|
+
|
|
41
|
+
@CacheAble("testCache") // auto cached
|
|
42
|
+
getTest(){
|
|
43
|
+
//todo
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@CacheEvict("testCache") // auto clear cache
|
|
47
|
+
setTest(){
|
|
48
|
+
//todo
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
test(){
|
|
52
|
+
const store = GetCacheStore(this.app);
|
|
53
|
+
store.set(key, value);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
57
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @Author: richen
|
|
3
|
-
* @Date: 2024-
|
|
3
|
+
* @Date: 2024-11-07 16:07:00
|
|
4
4
|
* @License: BSD (3-Clause)
|
|
5
5
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
|
6
6
|
* @HomePage: https://koatty.org/
|
|
@@ -71,6 +71,6 @@ export declare interface CacheEvictOpt {
|
|
|
71
71
|
* @param {Application} app
|
|
72
72
|
* @returns {*} {CacheStore}
|
|
73
73
|
*/
|
|
74
|
-
export declare function GetCacheStore(app
|
|
74
|
+
export declare function GetCacheStore(app?: Application): Promise<CacheStore>;
|
|
75
75
|
|
|
76
76
|
export { }
|