koatty_store 1.5.6 → 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 +51 -51
- package/CHANGELOG.md +4 -0
- package/dist/index.d.ts +100 -35
- package/dist/index.js +1322 -1345
- package/dist/index.mjs +1301 -1315
- package/dist/package.json +92 -89
- package/package.json +92 -89
package/.rollup.config.js
CHANGED
|
@@ -3,61 +3,61 @@
|
|
|
3
3
|
* @Usage:
|
|
4
4
|
* @Author: richen
|
|
5
5
|
* @Date: 2021-12-17 10:20:44
|
|
6
|
-
* @LastEditTime:
|
|
6
|
+
* @LastEditTime: 2023-02-18 23:21:06
|
|
7
7
|
*/
|
|
8
8
|
import json from "@rollup/plugin-json";
|
|
9
9
|
import typescript from 'rollup-plugin-typescript2';
|
|
10
10
|
// import babel from '@rollup/plugin-babel';
|
|
11
11
|
|
|
12
12
|
export default [
|
|
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
|
-
|
|
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,6 +2,10 @@
|
|
|
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.0](https://github.com/koatty/koatty_store/compare/v1.5.8...v1.6.0) (2023-02-18)
|
|
6
|
+
|
|
7
|
+
### [1.5.8](https://github.com/koatty/koatty_store/compare/v1.5.6...v1.5.8) (2023-01-13)
|
|
8
|
+
|
|
5
9
|
### [1.5.6](https://github.com/koatty/koatty_store/compare/v1.5.5...v1.5.6) (2022-11-03)
|
|
6
10
|
|
|
7
11
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @Author: richen
|
|
3
|
-
* @Date:
|
|
3
|
+
* @Date: 2023-02-19 01:08:28
|
|
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:
|
|
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
|
-
|
|
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):
|
|
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
|
-
|
|
789
|
+
declare class MemoryStore implements CacheStoreInterface {
|
|
769
790
|
client: any;
|
|
770
791
|
pool: any;
|
|
771
|
-
options:
|
|
792
|
+
options: MemoryStoreOpt;
|
|
772
793
|
/**
|
|
773
794
|
* Creates an instance of MemoryStore.
|
|
774
|
-
* @param {
|
|
795
|
+
* @param {MemoryStoreOpt} options
|
|
775
796
|
* @memberof MemoryStore
|
|
776
797
|
*/
|
|
777
|
-
constructor(options:
|
|
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
|
|
851
|
+
* @class RedisStore
|
|
824
852
|
*/
|
|
825
|
-
|
|
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
|
-
* @
|
|
830
|
-
* @
|
|
831
|
-
* @memberof ValidateUtil
|
|
873
|
+
* @returns {*}
|
|
874
|
+
* @memberof RedisStore
|
|
832
875
|
*/
|
|
833
|
-
|
|
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
|
-
|
|
843
|
-
type
|
|
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 { }
|