koatty_cacheable 1.3.2 → 1.3.7

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.
@@ -0,0 +1,63 @@
1
+ /*
2
+ * @Description:
3
+ * @Usage:
4
+ * @Author: richen
5
+ * @Date: 2021-12-17 10:20:44
6
+ * @LastEditTime: 2021-12-18 11:58:46
7
+ */
8
+ import json from "@rollup/plugin-json";
9
+ import typescript from 'rollup-plugin-typescript2';
10
+ // import babel from '@rollup/plugin-babel';
11
+
12
+ export default [
13
+ {
14
+ input: './src/index.ts',
15
+ output: [{
16
+ format: 'cjs',
17
+ file: './dist/index.js',
18
+ banner: require('./scripts/copyright')
19
+ }],
20
+ plugins: [
21
+ // babel({
22
+ // babelHelpers: "runtime",
23
+ // configFile: './babel.config.js',
24
+ // exclude: 'node_modules/**',
25
+ // }),
26
+ json(),
27
+ typescript({
28
+ tsconfigOverride: {
29
+ compilerOptions: {
30
+ declaration: false,
31
+ declarationMap: false,
32
+ module: "ESNext"
33
+ }
34
+ }
35
+ })
36
+ ]
37
+ },
38
+ {
39
+ input: './src/index.ts',
40
+ output: [{
41
+ format: 'es',
42
+ file: './dist/index.mjs',
43
+ banner: require('./scripts/copyright')
44
+ }],
45
+ plugins: [
46
+ // babel({
47
+ // babelHelpers: "runtime",
48
+ // configFile: './babel.config.js',
49
+ // exclude: 'node_modules/**',
50
+ // }),
51
+ json(),
52
+ typescript({
53
+ tsconfigOverride: {
54
+ compilerOptions: {
55
+ declaration: false,
56
+ declarationMap: false,
57
+ module: "ESNext"
58
+ }
59
+ }
60
+ })
61
+ ]
62
+ }
63
+ ]
package/CHANGELOG.md CHANGED
@@ -2,4 +2,4 @@
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.3.2](https://github.com/thinkkoa/koatty_cacheable/compare/v1.2.12...v1.3.2) (2021-11-20)
5
+ ### [1.3.7](https://github.com/thinkkoa/koatty_cacheable/compare/v1.3.6...v1.3.7) (2022-05-27)
package/dist/LICENSE ADDED
@@ -0,0 +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.
package/dist/README.md ADDED
@@ -0,0 +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
+
57
+ ```
package/dist/index.d.ts CHANGED
@@ -1,35 +1,47 @@
1
- import { CacheStore } from "koatty_store";
2
- import { Application } from 'koatty_container';
3
- /**
4
- * get instances of cacheStore
5
- *
6
- * @export
7
- * @returns {*}
8
- */
9
- export declare function GetCacheStore(app: Application): Promise<CacheStore>;
10
- /**
11
- * Decorate this method to support caching. Redis server config from db.ts.
12
- * The cache method returns a value to ensure that the next time the method is executed with the same parameters,
13
- * the results can be obtained directly from the cache without the need to execute the method again.
14
- *
15
- * @export
16
- * @param {string} cacheName cache name
17
- * @param {(number | number[])} [paramKey] The index of the arguments.
18
- * @param {number} [timeout=3600] cache timeout
19
- * @returns {MethodDecorator}
20
- */
21
- export declare function CacheAble(cacheName: string, paramKey?: number | number[], timeout?: number): MethodDecorator;
22
- /**
23
- *
24
- */
25
- export declare type eventTimes = "Before" | "After";
26
- /**
27
- * Decorating the execution of this method will trigger a cache clear operation. Redis server config from db.ts.
28
- *
29
- * @export
30
- * @param {string} cacheName cacheName cache name
31
- * @param {(number | number[])} [paramKey] The index of the arguments.
32
- * @param {eventTimes} [eventTime="Before"]
33
- * @returns
34
- */
35
- export declare function CacheEvict(cacheName: string, paramKey?: number | number[], eventTime?: eventTimes): (target: any, methodName: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
1
+ /*!
2
+ * @Author: richen
3
+ * @Date: 2022-05-27 11:35:52
4
+ * @License: BSD (3-Clause)
5
+ * @Copyright (c) - <richenlin(at)gmail.com>
6
+ * @HomePage: https://koatty.org/
7
+ */
8
+ import { Application } from 'koatty_container';
9
+ import { CacheStore } from 'koatty_store';
10
+
11
+ /**
12
+ * Decorate this method to support caching. Redis server config from db.ts.
13
+ * The cache method returns a value to ensure that the next time the method is executed with the same parameters,
14
+ * the results can be obtained directly from the cache without the need to execute the method again.
15
+ *
16
+ * @export
17
+ * @param {string} cacheName cache name
18
+ * @param {number} [timeout=3600] cache timeout
19
+ * @returns {MethodDecorator}
20
+ */
21
+ export declare function CacheAble(cacheName: string, timeout?: number): MethodDecorator;
22
+
23
+ /**
24
+ * Decorating the execution of this method will trigger a cache clear operation. Redis server config from db.ts.
25
+ *
26
+ * @export
27
+ * @param {string} cacheName cacheName cache name
28
+ * @param {eventTimes} [eventTime="Before"]
29
+ * @returns
30
+ */
31
+ export declare function CacheEvict(cacheName: string, eventTime?: eventTimes): (target: any, methodName: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
32
+
33
+ /**
34
+ *
35
+ */
36
+ export declare type eventTimes = "Before" | "After";
37
+
38
+ /**
39
+ * get instances of cacheStore
40
+ *
41
+ * @export
42
+ * @param {Application} app
43
+ * @returns {*} {CacheStore}
44
+ */
45
+ export declare function GetCacheStore(app: Application): Promise<CacheStore>;
46
+
47
+ export { }