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 {
2727 *
2828 * @param data not empty array of functions
2929 * @param redisClient
30+ * @param redisPrefix
3031 */
31- constructor ( data , redisClient ) {
32+ constructor ( data , redisClient , redisPrefix ) {
3233 this . _STORE_PREFIX = 'balancer' ;
3334 this . INC_VALUE = 1 ;
35+ this . redisPrefix = redisPrefix ;
3436 this . _redisClient = redisClient ;
3537 this . _data = data ;
3638 this . _storeKey = this . makeStoreKey ( data ) ;
@@ -85,7 +87,7 @@ class RedisBalancer {
8587 * @protected
8688 */
8789 makeStoreKey ( data ) {
88- let storeKeyArray = [ this . _STORE_PREFIX ] ;
90+ let storeKeyArray = [ this . _STORE_PREFIX , this . redisPrefix ] ;
8991 data . forEach ( ( method , index ) => {
9092 storeKeyArray . push ( index . toString ( ) ) ;
9193 } ) ;
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export default class RedisBalancer<T> {
1313 private _data : Array < T > ;
1414 private readonly _STORE_PREFIX = 'balancer' ;
1515 private readonly _redisClient : RedisClient ;
16+ private readonly redisPrefix : string ;
1617 private readonly INC_VALUE = 1 ;
1718
1819 private readonly _functions : RedisFunctions ;
@@ -21,8 +22,10 @@ export default class RedisBalancer<T> {
2122 *
2223 * @param data not empty array of functions
2324 * @param redisClient
25+ * @param redisPrefix
2426 */
25- constructor ( data : Array < T > , redisClient : RedisClient ) {
27+ constructor ( data : Array < T > , redisClient : RedisClient , redisPrefix : string ) {
28+ this . redisPrefix = redisPrefix ;
2629 this . _redisClient = redisClient ;
2730 this . _data = data ;
2831 this . _storeKey = this . makeStoreKey ( data ) ;
@@ -78,7 +81,7 @@ export default class RedisBalancer<T> {
7881 * @protected
7982 */
8083 protected makeStoreKey ( data : Array < T > ) : string {
81- let storeKeyArray : Array < string > = [ this . _STORE_PREFIX ] ;
84+ let storeKeyArray : Array < string > = [ this . _STORE_PREFIX , this . redisPrefix ] ;
8285 data . forEach ( ( method : T , index : number ) => {
8386 storeKeyArray . push ( index . toString ( ) ) ;
8487 } ) ;
You can’t perform that action at this time.
0 commit comments