koatty_store 1.5.8 → 1.6.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/.rollup.config.js CHANGED
@@ -1,63 +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
- }
1
+ /*
2
+ * @Description:
3
+ * @Usage:
4
+ * @Author: richen
5
+ * @Date: 2021-12-17 10:20:44
6
+ * @LastEditTime: 2023-02-18 23:21:06
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
63
  ]
package/CHANGELOG.md CHANGED
@@ -2,19 +2,28 @@
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.5.8](https://github.com/koatty/koatty_store/compare/v1.5.6...v1.5.8) (2023-01-13)
6
-
7
- ### [1.5.6](https://github.com/koatty/koatty_store/compare/v1.5.5...v1.5.6) (2022-11-03)
5
+ ### [1.6.1](https://github.com/koatty/koatty_store/compare/v1.6.0...v1.6.1) (2023-07-28)
8
6
 
9
7
 
10
8
  ### Bug Fixes
11
9
 
12
- * upgrade deps ([cf54da2](https://github.com/koatty/koatty_store/commit/cf54da2c9e13ba843efa44b4631f3144946ebdff))
13
-
14
- ### [1.5.5](https://github.com/koatty/koatty_store/compare/v1.5.4...v1.5.5) (2022-05-27)
15
-
16
- ### [1.5.4](https://github.com/koatty/koatty_store/compare/v1.5.2...v1.5.4) (2021-12-02)
17
-
18
- ### [1.5.2](https://github.com/koatty/koatty_store/compare/v1.4.10...v1.5.2) (2021-12-02)
19
-
20
- ### [1.4.10](https://github.com/koatty/koatty_store/compare/v1.4.8...v1.4.10) (2021-11-20)
10
+ * remove words ([604d31d](https://github.com/koatty/koatty_store/commit/604d31df38814a530b32605668542821b608cb7d))
11
+
12
+ ## [1.6.0](https://github.com/koatty/koatty_store/compare/v1.5.8...v1.6.0) (2023-02-18)
13
+
14
+ ### [1.5.8](https://github.com/koatty/koatty_store/compare/v1.5.6...v1.5.8) (2023-01-13)
15
+
16
+ ### [1.5.6](https://github.com/koatty/koatty_store/compare/v1.5.5...v1.5.6) (2022-11-03)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * upgrade deps ([cf54da2](https://github.com/koatty/koatty_store/commit/cf54da2c9e13ba843efa44b4631f3144946ebdff))
22
+
23
+ ### [1.5.5](https://github.com/koatty/koatty_store/compare/v1.5.4...v1.5.5) (2022-05-27)
24
+
25
+ ### [1.5.4](https://github.com/koatty/koatty_store/compare/v1.5.2...v1.5.4) (2021-12-02)
26
+
27
+ ### [1.5.2](https://github.com/koatty/koatty_store/compare/v1.4.10...v1.5.2) (2021-12-02)
28
+
29
+ ### [1.4.10](https://github.com/koatty/koatty_store/compare/v1.4.8...v1.4.10) (2021-11-20)
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,2 +1,2 @@
1
- # koatty_store
2
- Cache store (memory or reids) for koatty.
1
+ # koatty_store
2
+ Cache store (memory or reids) for koatty.
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,2 +1,2 @@
1
- # koatty_store
2
- Cache store (memory or reids) for koatty.
1
+ # koatty_store
2
+ Cache store (memory or reids) for koatty.
package/dist/index.d.ts CHANGED
@@ -1,13 +1,20 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2023-01-13 12:11:54
3
+ * @Date: 2023-07-28 21:00:59
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
7
7
  */
8
8
  /// <reference types="node" />
9
9
 
10
+ import { Cluster } from 'ioredis';
11
+ import { ClusterOptions } from 'ioredis';
12
+ import { default as default_2 } from 'ioredis/built/cluster';
13
+ import { default as default_3 } from 'ioredis/built/Redis';
10
14
  import { EventEmitter } from 'events';
15
+ import genericPool from 'generic-pool';
16
+ import { Redis } from 'ioredis';
17
+ import { RedisOptions } from 'ioredis';
11
18
 
12
19
  /**
13
20
  *
@@ -16,8 +23,7 @@ import { EventEmitter } from 'events';
16
23
  * @class Store
17
24
  */
18
25
  export declare class CacheStore {
19
- client: any;
20
- pool: any;
26
+ client: MemoryStore | RedisStore;
21
27
  options: StoreOptions;
22
28
  /**
23
29
  * Creates an instance of CacheStore.
@@ -25,10 +31,17 @@ export declare class CacheStore {
25
31
  * @memberof CacheStore
26
32
  */
27
33
  constructor(options: StoreOptions);
28
- getConnection(): void;
34
+ /**
35
+ *
36
+ *
37
+ * @static
38
+ * @returns
39
+ */
40
+ static getInstance(options: StoreOptions): CacheStore;
41
+ getConnection(): MemoryCache | Promise<default_2 | default_3>;
29
42
  close(): Promise<void>;
30
43
  release(conn: any): Promise<void>;
31
- defineCommand(name: string, scripts: any): void;
44
+ defineCommand(name: string, scripts: any): Promise<any>;
32
45
  getCompare(name: string, value: string | number): Promise<any>;
33
46
  /**
34
47
  * handler for native client
@@ -260,6 +273,14 @@ export declare class CacheStore {
260
273
  smove(source: string, destination: string, member: string): Promise<any>;
261
274
  }
262
275
 
276
+ declare interface CacheStoreInterface {
277
+ getConnection(): void;
278
+ close(): Promise<void>;
279
+ release(conn: any): Promise<void>;
280
+ defineCommand(name: string, scripts: any): void;
281
+ getCompare(name: string, value: string | number): Promise<any>;
282
+ }
283
+
263
284
  declare class MemoryCache extends EventEmitter {
264
285
  options: MemoryCacheOptions;
265
286
  currentDBIndex: number;
@@ -765,16 +786,16 @@ declare interface MemoryCacheOptions {
765
786
  database: number;
766
787
  }
767
788
 
768
- export declare class MemoryStore extends CacheStore {
789
+ declare class MemoryStore implements CacheStoreInterface {
769
790
  client: any;
770
791
  pool: any;
771
- options: StoreOptions;
792
+ options: MemoryStoreOpt;
772
793
  /**
773
794
  * Creates an instance of MemoryStore.
774
- * @param {StoreOptions} options
795
+ * @param {MemoryStoreOpt} options
775
796
  * @memberof MemoryStore
776
797
  */
777
- constructor(options: StoreOptions);
798
+ constructor(options: MemoryStoreOpt);
778
799
  /**
779
800
  * getConnection
780
801
  *
@@ -816,51 +837,95 @@ export declare class MemoryStore extends CacheStore {
816
837
  getCompare(name: string, value: string | number): Promise<any>;
817
838
  }
818
839
 
840
+ declare interface MemoryStoreOpt {
841
+ type: string;
842
+ keyPrefix?: string;
843
+ db?: number;
844
+ timeout?: number;
845
+ }
846
+
819
847
  /**
820
848
  *
821
849
  *
822
850
  * @export
823
- * @class Store
851
+ * @class RedisStore
824
852
  */
825
- export declare class Store {
853
+ declare class RedisStore implements CacheStoreInterface {
854
+ options: RedisStoreOpt;
855
+ pool: genericPool.Pool<Redis | Cluster>;
856
+ client: Redis | Cluster;
857
+ /**
858
+ * Creates an instance of RedisStore.
859
+ * @param {RedisStoreOpt} options
860
+ * @memberof RedisStore
861
+ */
862
+ constructor(options: RedisStoreOpt);
826
863
  /**
864
+ * create connection by native
827
865
  *
866
+ * @param {number} [connNum=0]
867
+ * @returns {*} {Promise<Redis | Cluster>}
868
+ * @memberof RedisStore
869
+ */
870
+ /**
871
+ * get connection from pool
828
872
  *
829
- * @static
830
- * @returns
831
- * @memberof ValidateUtil
873
+ * @returns {*}
874
+ * @memberof RedisStore
832
875
  */
833
- static getInstance(options: StoreOptions): CacheStore;
876
+ getConnection(): Promise<Cluster | Redis>;
877
+ /**
878
+ * close connection
879
+ *
880
+ * @returns {*}
881
+ * @memberof RedisStore
882
+ */
883
+ close(): Promise<void>;
884
+ /**
885
+ *
886
+ *
887
+ * @param {*} conn
888
+ * @returns {*}
889
+ * @memberof RedisStore
890
+ */
891
+ release(conn: any): Promise<void>;
892
+ /**
893
+ * defineCommand
894
+ *
895
+ * @param {string} name
896
+ * @param {{ numberOfKeys?: number; lua?: string; }} scripts
897
+ * @returns {*}
898
+ * @memberof RedisStore
899
+ */
900
+ defineCommand(name: string, scripts: {
901
+ numberOfKeys?: number;
902
+ lua?: string;
903
+ }): Promise<any>;
904
+ /**
905
+ * get and compare value
906
+ *
907
+ * @param {string} name
908
+ * @param {(string | number)} value
909
+ * @returns {*} {Promise<any>}
910
+ * @memberof RedisStore
911
+ */
912
+ getCompare(name: string, value: string | number): Promise<any>;
834
913
  }
835
914
 
836
915
  /**
837
- *
838
- *
839
- * @export
840
- * @interface StoreOptions
916
+ * @description:
917
+ * @return {*}
841
918
  */
842
- export declare interface StoreOptions {
843
- type?: string;
844
- keyPrefix?: string;
845
- host?: string | Array<string>;
846
- port?: number | Array<number>;
847
- username?: string;
848
- password?: string;
849
- db?: number;
919
+ declare interface RedisStoreOpt extends RedisOptions, ClusterOptions {
920
+ type: string;
850
921
  timeout?: number;
851
922
  poolSize?: number;
852
- connectTimeout?: number;
853
- name?: string;
854
- sentinelUsername?: string;
855
- sentinelPassword?: string;
856
- sentinels?: Array<{
857
- host: string;
858
- port: number;
859
- }>;
860
923
  clusters?: Array<{
861
924
  host: string;
862
925
  port: number;
863
926
  }>;
864
927
  }
865
928
 
929
+ export declare type StoreOptions = MemoryStoreOpt | RedisStoreOpt;
930
+
866
931
  export { }