@pi-r/redis 0.2.10 → 0.2.11
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/client/index.js +16 -13
- package/package.json +1 -1
package/client/index.js
CHANGED
|
@@ -40,13 +40,15 @@ function getClient(db, options, poolKey) {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
function removePoolProperties(options) {
|
|
43
|
+
var _a;
|
|
43
44
|
if (!options.uuidKey && ('socket' in options || 'isolationPoolOptions' in options)) {
|
|
44
|
-
return { ...options, socket: options.socket
|
|
45
|
+
return { ...options, socket: ((_a = options.socket) === null || _a === void 0 ? void 0 : _a.tls) ? { tls: true } : undefined, isolationPoolOptions: undefined };
|
|
45
46
|
}
|
|
46
47
|
return options;
|
|
47
48
|
}
|
|
48
|
-
const getPoolKey = (options) => options.url + '_' + (options.username || '') + '_' + (options.password || '') + '_' + (options.database
|
|
49
|
+
const getPoolKey = (options) => { var _a, _b; return options.url + '_' + (options.username || '') + '_' + (options.password || '') + '_' + ((_a = options.database) !== null && _a !== void 0 ? _a : '') + '_' + (((_b = options.socket) === null || _b === void 0 ? void 0 : _b.tls) ? '1' : '0') + '_' + (options.legacyMode ? '1' : '0'); };
|
|
49
50
|
async function setCredential(item) {
|
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
50
52
|
if (!REDIS_V4) {
|
|
51
53
|
throw (0, types_1.errorValue)("Upgrade client to latest version", "redis" + '@' + Db.getPackageVersion("redis"));
|
|
52
54
|
}
|
|
@@ -81,7 +83,7 @@ async function setCredential(item) {
|
|
|
81
83
|
if (!uri) {
|
|
82
84
|
throw (0, types_1.errorMessage)("redis", 'Not defined - uri');
|
|
83
85
|
}
|
|
84
|
-
if (client.socket
|
|
86
|
+
if ((_a = client.socket) === null || _a === void 0 ? void 0 : _a.tls) {
|
|
85
87
|
this.readTLSConfig(client.socket);
|
|
86
88
|
}
|
|
87
89
|
client.url = uri;
|
|
@@ -96,7 +98,7 @@ async function setCredential(item) {
|
|
|
96
98
|
let pool;
|
|
97
99
|
username = undefined;
|
|
98
100
|
password = undefined;
|
|
99
|
-
if (typeof usePool === 'string' && (username = client.username || (0, util_1.parseConnectionString)(uri)
|
|
101
|
+
if (typeof usePool === 'string' && (username = client.username || ((_b = (0, util_1.parseConnectionString)(uri)) === null || _b === void 0 ? void 0 : _b.username))) {
|
|
100
102
|
[password, pool] = DbPool.validateKey(POOL_STATE, username, usePool);
|
|
101
103
|
if (pool) {
|
|
102
104
|
pool.add(item, password);
|
|
@@ -111,19 +113,19 @@ async function setCredential(item) {
|
|
|
111
113
|
if (config) {
|
|
112
114
|
const { min, max, idle, queue_max, queue_idle } = config;
|
|
113
115
|
if (min >= 0) {
|
|
114
|
-
poolOptions.min
|
|
116
|
+
(_c = poolOptions.min) !== null && _c !== void 0 ? _c : (poolOptions.min = min);
|
|
115
117
|
}
|
|
116
118
|
if (max > 0) {
|
|
117
|
-
poolOptions.max
|
|
119
|
+
(_d = poolOptions.max) !== null && _d !== void 0 ? _d : (poolOptions.max = max);
|
|
118
120
|
}
|
|
119
121
|
if (idle > 0) {
|
|
120
|
-
poolOptions.idleTimeoutMillis
|
|
122
|
+
(_e = poolOptions.idleTimeoutMillis) !== null && _e !== void 0 ? _e : (poolOptions.idleTimeoutMillis = idle);
|
|
121
123
|
}
|
|
122
124
|
if (queue_max >= 0) {
|
|
123
|
-
poolOptions.maxWaitingClients
|
|
125
|
+
(_f = poolOptions.maxWaitingClients) !== null && _f !== void 0 ? _f : (poolOptions.maxWaitingClients = queue_max);
|
|
124
126
|
}
|
|
125
127
|
if (queue_idle > 0) {
|
|
126
|
-
poolOptions.acquireTimeoutMillis
|
|
128
|
+
(_g = poolOptions.acquireTimeoutMillis) !== null && _g !== void 0 ? _g : (poolOptions.acquireTimeoutMillis = queue_idle);
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
131
|
try {
|
|
@@ -147,6 +149,7 @@ async function executeQuery(item, options) {
|
|
|
147
149
|
}
|
|
148
150
|
exports.executeQuery = executeQuery;
|
|
149
151
|
async function executeBatchQuery(batch, options = '', outResult) {
|
|
152
|
+
var _a, _b;
|
|
150
153
|
const length = batch.length;
|
|
151
154
|
if (length === 0) {
|
|
152
155
|
return [];
|
|
@@ -175,7 +178,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
175
178
|
const caching = this.hasCache("redis", sessionKey);
|
|
176
179
|
const tasks = new Array(length);
|
|
177
180
|
const clients = [];
|
|
178
|
-
let redisClient, redisCredential, redisCache = 0, onceCredential = connectOnce ? batch[0].options
|
|
181
|
+
let redisClient, redisCredential, redisCache = 0, onceCredential = connectOnce ? (_a = batch[0].options) === null || _a === void 0 ? void 0 : _a.client : undefined;
|
|
179
182
|
const getConnection = async (item, credential) => {
|
|
180
183
|
item.transactionState = 64;
|
|
181
184
|
let client;
|
|
@@ -224,7 +227,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
224
227
|
continue;
|
|
225
228
|
}
|
|
226
229
|
item.transactionState = 1;
|
|
227
|
-
const uuidKey = (credential.uuidKey || (credential.uuidKey = (onceCredential ? batch[0] : item).credential
|
|
230
|
+
const uuidKey = (credential.uuidKey || (credential.uuidKey = (_b = (onceCredential ? batch[0] : item).credential) === null || _b === void 0 ? void 0 : _b.uuidKey));
|
|
228
231
|
const targetObject = typeof checkObject === 'string' ? this.hasCoerce("redis", 'options', uuidKey) && (0, types_1.asFunction)(checkObject) : checkObject;
|
|
229
232
|
const renewCache = ignoreCache === 0;
|
|
230
233
|
const cacheValue = renewCache ? { sessionKey, renewCache } : sessionKey;
|
|
@@ -313,11 +316,11 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
313
316
|
const flags = setOptions.set;
|
|
314
317
|
if (flags) {
|
|
315
318
|
if ('NX' in flags) {
|
|
316
|
-
NX
|
|
319
|
+
NX !== null && NX !== void 0 ? NX : (NX = !!flags.NX);
|
|
317
320
|
delete flags.NX;
|
|
318
321
|
}
|
|
319
322
|
if ('XX' in flags) {
|
|
320
|
-
XX
|
|
323
|
+
XX !== null && XX !== void 0 ? XX : (XX = !!flags.XX);
|
|
321
324
|
delete flags.XX;
|
|
322
325
|
}
|
|
323
326
|
if ('EX' in flags) {
|