vona-module-a-redis 5.0.13 → 5.0.16
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.
|
@@ -18,29 +18,34 @@ declare module 'vona' {
|
|
|
18
18
|
}
|
|
19
19
|
/** bean: end */
|
|
20
20
|
/** service: begin */
|
|
21
|
-
export * from '../service/
|
|
21
|
+
export * from '../service/redis.ts';
|
|
22
|
+
export * from '../service/redisClient_.ts';
|
|
22
23
|
import 'vona';
|
|
23
24
|
declare module 'vona-module-a-bean' {
|
|
24
25
|
interface IServiceRecord {
|
|
25
|
-
'a-redis:
|
|
26
|
+
'a-redis:redis': never;
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
declare module 'vona-module-a-redis' {
|
|
29
|
-
interface
|
|
30
|
+
interface ServiceRedis {
|
|
31
|
+
}
|
|
32
|
+
interface ServiceRedis {
|
|
33
|
+
get $beanFullName(): 'a-redis.service.redis';
|
|
34
|
+
get $onionName(): 'a-redis:redis';
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
37
|
/** service: end */
|
|
33
38
|
/** service: begin */
|
|
34
|
-
import type {
|
|
39
|
+
import type { ServiceRedis } from '../service/redis.ts';
|
|
35
40
|
export interface IModuleService {
|
|
36
|
-
'
|
|
41
|
+
'redis': ServiceRedis;
|
|
37
42
|
}
|
|
38
43
|
/** service: end */
|
|
39
44
|
/** service: begin */
|
|
40
45
|
import 'vona';
|
|
41
46
|
declare module 'vona' {
|
|
42
47
|
interface IBeanRecordGeneral {
|
|
43
|
-
'a-redis.service.
|
|
48
|
+
'a-redis.service.redis': ServiceRedis;
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
51
|
/** service: end */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IRedisClientRecord } from '../types/redis.ts';
|
|
2
2
|
import { BeanBase } from 'vona';
|
|
3
|
-
import { ServiceRedisClient } from '../service/
|
|
3
|
+
import { ServiceRedisClient } from '../service/redisClient_.ts';
|
|
4
4
|
export declare class BeanRedis extends BeanBase {
|
|
5
5
|
getClient(clientName?: keyof IRedisClientRecord): ServiceRedisClient;
|
|
6
6
|
get(clientName?: keyof IRedisClientRecord): import("ioredis").default;
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,10 @@ import { BeanInfo, BeanBase, cast, deepExtend, BeanSimple, combineConfigDefault,
|
|
|
2
2
|
import { Service, Bean, Scope } from 'vona-module-a-bean';
|
|
3
3
|
import { Redis } from 'ioredis';
|
|
4
4
|
|
|
5
|
-
var _dec$
|
|
6
|
-
let ServiceRedisClient = (_dec$
|
|
5
|
+
var _dec$3, _dec2$3, _class$3;
|
|
6
|
+
let ServiceRedisClient = (_dec$3 = Service(), _dec2$3 = BeanInfo({
|
|
7
7
|
module: "a-redis"
|
|
8
|
-
}), _dec$
|
|
8
|
+
}), _dec$3(_class$3 = _dec2$3(_class$3 = class ServiceRedisClient extends BeanBase {
|
|
9
9
|
constructor(...args) {
|
|
10
10
|
super(...args);
|
|
11
11
|
this._redisInstance = void 0;
|
|
@@ -18,10 +18,9 @@ let ServiceRedisClient = (_dec$2 = Service(), _dec2$2 = BeanInfo({
|
|
|
18
18
|
this._redisInstance = this._createClient(clientName);
|
|
19
19
|
}
|
|
20
20
|
async __dispose__() {
|
|
21
|
-
await this._redisInstance?.
|
|
21
|
+
await this._redisInstance?.disconnect();
|
|
22
22
|
}
|
|
23
23
|
_createClient(clientName) {
|
|
24
|
-
clientName = clientName || 'default';
|
|
25
24
|
const configRedis = this.app.config.redis;
|
|
26
25
|
const configClient = configRedis.clients[clientName];
|
|
27
26
|
if (!configClient) throw new Error(`redis client not found: ${clientName}`);
|
|
@@ -35,6 +34,25 @@ let ServiceRedisClient = (_dec$2 = Service(), _dec2$2 = BeanInfo({
|
|
|
35
34
|
return new Redis(configNode);
|
|
36
35
|
}
|
|
37
36
|
}
|
|
37
|
+
}) || _class$3) || _class$3);
|
|
38
|
+
|
|
39
|
+
var _dec$2, _dec2$2, _class$2;
|
|
40
|
+
let BeanRedis = (_dec$2 = Bean(), _dec2$2 = BeanInfo({
|
|
41
|
+
module: "a-redis"
|
|
42
|
+
}), _dec$2(_class$2 = _dec2$2(_class$2 = class BeanRedis extends BeanBase {
|
|
43
|
+
getClient(clientName) {
|
|
44
|
+
return this.app.bean._getBeanSelector(ServiceRedisClient, clientName ?? 'default');
|
|
45
|
+
}
|
|
46
|
+
get(clientName) {
|
|
47
|
+
const client = this.getClient(clientName);
|
|
48
|
+
return client.instance;
|
|
49
|
+
}
|
|
50
|
+
}) || _class$2) || _class$2);
|
|
51
|
+
|
|
52
|
+
var _dec$1, _dec2$1, _class$1;
|
|
53
|
+
let ServiceRedis = (_dec$1 = Service(), _dec2$1 = BeanInfo({
|
|
54
|
+
module: "a-redis"
|
|
55
|
+
}), _dec$1(_class$1 = _dec2$1(_class$1 = class ServiceRedis extends BeanBase {
|
|
38
56
|
async clearAllData() {
|
|
39
57
|
const app = this.app;
|
|
40
58
|
// clear keys
|
|
@@ -66,19 +84,6 @@ let ServiceRedisClient = (_dec$2 = Service(), _dec2$2 = BeanInfo({
|
|
|
66
84
|
await redis.del(keysDel);
|
|
67
85
|
}
|
|
68
86
|
}
|
|
69
|
-
}) || _class$2) || _class$2);
|
|
70
|
-
|
|
71
|
-
var _dec$1, _dec2$1, _class$1;
|
|
72
|
-
let BeanRedis = (_dec$1 = Bean(), _dec2$1 = BeanInfo({
|
|
73
|
-
module: "a-redis"
|
|
74
|
-
}), _dec$1(_class$1 = _dec2$1(_class$1 = class BeanRedis extends BeanBase {
|
|
75
|
-
getClient(clientName) {
|
|
76
|
-
return this.app.bean._getBeanSelector(ServiceRedisClient, clientName);
|
|
77
|
-
}
|
|
78
|
-
get(clientName) {
|
|
79
|
-
const client = this.getClient(clientName);
|
|
80
|
-
return client.instance;
|
|
81
|
-
}
|
|
82
87
|
}) || _class$1) || _class$1);
|
|
83
88
|
|
|
84
89
|
class Main extends BeanSimple {
|
|
@@ -132,4 +137,4 @@ let ScopeModuleARedis = (_dec = Scope(), _dec2 = BeanInfo({
|
|
|
132
137
|
|
|
133
138
|
/** scope: end */
|
|
134
139
|
|
|
135
|
-
export { BeanRedis, Main, ScopeModuleARedis, ServiceRedisClient, configDefault };
|
|
140
|
+
export { BeanRedis, Main, ScopeModuleARedis, ServiceRedis, ServiceRedisClient, configDefault };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import type { IRedisClientRecord } from '../types/redis.ts';
|
|
1
2
|
import { Redis } from 'ioredis';
|
|
2
3
|
import { BeanBase } from 'vona';
|
|
3
4
|
export declare class ServiceRedisClient extends BeanBase {
|
|
4
5
|
private _redisInstance;
|
|
5
6
|
get instance(): Redis;
|
|
6
|
-
protected __init__(clientName
|
|
7
|
+
protected __init__(clientName: keyof IRedisClientRecord): void;
|
|
7
8
|
protected __dispose__(): Promise<void>;
|
|
8
9
|
private _createClient;
|
|
9
|
-
clearAllData(): Promise<void>;
|
|
10
|
-
private _clearRedisKeys;
|
|
11
10
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-module-a-redis",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.16",
|
|
5
5
|
"title": "a-redis",
|
|
6
6
|
"vonaModule": {
|
|
7
7
|
"dependencies": {},
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"static"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"ioredis": "^5.
|
|
32
|
+
"ioredis": "^5.7.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"clean-package": "^2.2.0",
|