File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -27,10 +27,12 @@ class RedisBalancer {
27
27
*
28
28
* @param data not empty array of functions
29
29
* @param redisClient
30
+ * @param redisPrefix
30
31
*/
31
- constructor ( data , redisClient ) {
32
+ constructor ( data , redisClient , redisPrefix ) {
32
33
this . _STORE_PREFIX = 'balancer' ;
33
34
this . INC_VALUE = 1 ;
35
+ this . redisPrefix = redisPrefix ;
34
36
this . _redisClient = redisClient ;
35
37
this . _data = data ;
36
38
this . _storeKey = this . makeStoreKey ( data ) ;
@@ -85,7 +87,7 @@ class RedisBalancer {
85
87
* @protected
86
88
*/
87
89
makeStoreKey ( data ) {
88
- let storeKeyArray = [ this . _STORE_PREFIX ] ;
90
+ let storeKeyArray = [ this . _STORE_PREFIX , this . redisPrefix ] ;
89
91
data . forEach ( ( method , index ) => {
90
92
storeKeyArray . push ( index . toString ( ) ) ;
91
93
} ) ;
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export default class RedisBalancer<T> {
13
13
private _data : Array < T > ;
14
14
private readonly _STORE_PREFIX = 'balancer' ;
15
15
private readonly _redisClient : RedisClient ;
16
+ private readonly redisPrefix : string ;
16
17
private readonly INC_VALUE = 1 ;
17
18
18
19
private readonly _functions : RedisFunctions ;
@@ -21,8 +22,10 @@ export default class RedisBalancer<T> {
21
22
*
22
23
* @param data not empty array of functions
23
24
* @param redisClient
25
+ * @param redisPrefix
24
26
*/
25
- constructor ( data : Array < T > , redisClient : RedisClient ) {
27
+ constructor ( data : Array < T > , redisClient : RedisClient , redisPrefix : string ) {
28
+ this . redisPrefix = redisPrefix ;
26
29
this . _redisClient = redisClient ;
27
30
this . _data = data ;
28
31
this . _storeKey = this . makeStoreKey ( data ) ;
@@ -78,7 +81,7 @@ export default class RedisBalancer<T> {
78
81
* @protected
79
82
*/
80
83
protected makeStoreKey ( data : Array < T > ) : string {
81
- let storeKeyArray : Array < string > = [ this . _STORE_PREFIX ] ;
84
+ let storeKeyArray : Array < string > = [ this . _STORE_PREFIX , this . redisPrefix ] ;
82
85
data . forEach ( ( method : T , index : number ) => {
83
86
storeKeyArray . push ( index . toString ( ) ) ;
84
87
} ) ;
You can’t perform that action at this time.
0 commit comments