@ikonintegration/ikapi 2.6.7 → 2.6.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikonintegration/ikapi",
3
- "version": "2.6.7",
3
+ "version": "2.6.10",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "module": "main.js",
@@ -81,10 +81,7 @@ export default class IKCache_Redis extends IKCache {
81
81
  }
82
82
  _isRedisClientV4() {
83
83
  let isV4 = false;
84
- try {
85
- const test = require('redis').createClient({});
86
- if (test.connect) isV4 = true;
87
- }
84
+ try { isV4 = !!require('redis').createCluster; }
88
85
  catch (e) { }
89
86
  return isV4;
90
87
  }
@@ -123,14 +120,19 @@ export default class IKCache_Redis extends IKCache {
123
120
  //redis v4 & v3 compatibility
124
121
  if (connection && connection.connect) await connection.connect();
125
122
  //
126
- connectedHandler = () => {
123
+ const connectedHandler = () => {
127
124
  this.connection = connection;
128
125
  if (this.awaitingConnectionQueue) this.awaitingConnectionQueue.forEach((resolve) => resolve());
129
126
  this.awaitingConnectionQueue = null;
130
127
  resolve();
131
128
  }
129
+ //reached here on v4, everything is connected
130
+ if (isV4) {
131
+ connectedHandler();
132
+ return;
133
+ }
134
+ //v3 <=
132
135
  connection.on('connect', connectedHandler);
133
- if (isV4) connectedHandler(); //reached here on v4, everything is connected
134
136
  connection.on('error', (err) => {
135
137
  localConsole.error(err);
136
138
  if (this.awaitingConnectionQueue) this.awaitingConnectionQueue.forEach((resolve) => resolve()); //fulfill, error will be thrown