vona-module-a-redis 5.0.26 → 5.0.28

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/dist/index.js CHANGED
@@ -2,12 +2,12 @@ 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
- function getRedisClientKeyPrefix(clientName, appInfo) {
6
- const mode = ['test', 'dev'].includes(appInfo.configMeta.mode) ? '_local' : '';
7
- return `${clientName}_${appInfo.name}${mode}:`;
5
+ function getRedisClientKeyPrefix(clientName, app) {
6
+ const mode = ['test', 'dev'].includes(app.configMeta.mode) ? '_local' : '';
7
+ return `${clientName}_${app.name}${mode}:`;
8
8
  }
9
- function prepareRedisClientKeyPrefix(keyPrefix, clientName, appInfo) {
10
- return keyPrefix === true ? getRedisClientKeyPrefix(clientName, appInfo) : keyPrefix;
9
+ function prepareRedisClientKeyPrefix(keyPrefix, clientName, app) {
10
+ return keyPrefix === true ? getRedisClientKeyPrefix(clientName, app) : keyPrefix;
11
11
  }
12
12
 
13
13
  var _dec$3, _dec2$3, _class$3;
@@ -71,16 +71,16 @@ let ServiceRedis = (_dec$1 = Service(), _dec2$1 = BeanInfo({
71
71
  await this._clearRedisKeys(app.bean.redis.get('queue'), `${getRedisClientKeyPrefix('bull', app)}*`);
72
72
  // broadcast channel has subscribed
73
73
  // await _clearRedisKeys(app.redis.get('broadcast'), `${getRedisClientKeyPrefix('broadcast', app)}*`);
74
- // redlock
75
- for (const clientName of this.$scope.redlock.config.redlock.clients) {
76
- await this._clearRedisKeys(app.bean.redis.get(clientName), `${getRedisClientKeyPrefix('redlock', app)}*`);
77
- }
78
- for (const clientName in app.config.redis.clients) {
79
- if (['redlock', 'limiter', 'queue', 'broadcast'].includes(clientName)) continue;
80
- if (clientName.includes('redlock')) continue;
81
- const client = app.config.redis.clients[clientName];
82
- const keyPrefix = prepareRedisClientKeyPrefix(client.keyPrefix, clientName, this.app);
83
- await this._clearRedisKeys(app.bean.redis.get(clientName), `${keyPrefix}*`);
74
+ for (const _clientName in app.config.redis.clients) {
75
+ const clientName = _clientName;
76
+ if (['limiter', 'queue', 'broadcast'].includes(clientName)) continue;
77
+ if (clientName.startsWith('redlock')) {
78
+ await this._clearRedisKeys(app.bean.redis.get(clientName), `${getRedisClientKeyPrefix('redlock', app)}*`);
79
+ } else {
80
+ const client = app.config.redis.clients[clientName];
81
+ const keyPrefix = prepareRedisClientKeyPrefix(client.keyPrefix, clientName, this.app);
82
+ await this._clearRedisKeys(app.bean.redis.get(clientName), `${keyPrefix}*`);
83
+ }
84
84
  }
85
85
  }
86
86
  async _clearRedisKeys(redis, pattern) {
@@ -1,3 +1,3 @@
1
- import type { VonaAppInfo, VonaApplication } from 'vona';
2
- export declare function getRedisClientKeyPrefix(clientName: string, appInfo: VonaAppInfo | VonaApplication): string;
3
- export declare function prepareRedisClientKeyPrefix(keyPrefix: string | true | undefined, clientName: string, appInfo: VonaAppInfo | VonaApplication): string | undefined;
1
+ import type { VonaApplication } from 'vona';
2
+ export declare function getRedisClientKeyPrefix(clientName: string, app: VonaApplication): string;
3
+ export declare function prepareRedisClientKeyPrefix(keyPrefix: string | true | undefined, clientName: string, app: VonaApplication): string | undefined;
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.26",
4
+ "version": "5.0.28",
5
5
  "title": "a-redis",
6
6
  "vonaModule": {
7
7
  "dependencies": {},