@pi-r/redis 0.6.6 → 0.6.8
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 +15 -12
- package/package.json +4 -4
package/client/index.js
CHANGED
|
@@ -40,13 +40,15 @@ async 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) && POOL_ACTIVE.has(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
49
|
const getPoolKey = (options) => options.url && JSON.stringify(options);
|
|
49
50
|
async function setCredential(item) {
|
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
50
52
|
const credential = this.getCredential(item);
|
|
51
53
|
const options = item.options || (item.options = {});
|
|
52
54
|
const client = (0, types_1.isPlainObject)(options.client) ? options.client : options.client = {};
|
|
@@ -78,7 +80,7 @@ async function setCredential(item) {
|
|
|
78
80
|
if (!uri) {
|
|
79
81
|
throw (0, types_1.errorMessage)("redis", 'Not defined - uri');
|
|
80
82
|
}
|
|
81
|
-
if (client.socket
|
|
83
|
+
if ((_a = client.socket) === null || _a === void 0 ? void 0 : _a.tls) {
|
|
82
84
|
this.readTLSConfig(client.socket);
|
|
83
85
|
}
|
|
84
86
|
client.url = uri;
|
|
@@ -96,7 +98,7 @@ async function setCredential(item) {
|
|
|
96
98
|
username = undefined;
|
|
97
99
|
password = undefined;
|
|
98
100
|
if ((0, types_1.isString)(usePool)) {
|
|
99
|
-
if (username = client.username || (0, util_1.parseConnectionString)(uri)
|
|
101
|
+
if (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);
|
|
@@ -113,22 +115,22 @@ async function setCredential(item) {
|
|
|
113
115
|
if (config) {
|
|
114
116
|
const { min, max, idle, queue_max, queue_idle, timeout } = config;
|
|
115
117
|
if (min >= 0) {
|
|
116
|
-
poolOptions.min
|
|
118
|
+
(_c = poolOptions.min) !== null && _c !== void 0 ? _c : (poolOptions.min = min);
|
|
117
119
|
}
|
|
118
120
|
if (max > 0) {
|
|
119
|
-
poolOptions.max
|
|
121
|
+
(_d = poolOptions.max) !== null && _d !== void 0 ? _d : (poolOptions.max = max);
|
|
120
122
|
}
|
|
121
123
|
if (idle > 0) {
|
|
122
|
-
poolOptions.idleTimeoutMillis
|
|
124
|
+
(_e = poolOptions.idleTimeoutMillis) !== null && _e !== void 0 ? _e : (poolOptions.idleTimeoutMillis = idle);
|
|
123
125
|
}
|
|
124
126
|
if (queue_max >= 0) {
|
|
125
|
-
poolOptions.maxWaitingClients
|
|
127
|
+
(_f = poolOptions.maxWaitingClients) !== null && _f !== void 0 ? _f : (poolOptions.maxWaitingClients = queue_max);
|
|
126
128
|
}
|
|
127
129
|
if (queue_idle > 0) {
|
|
128
|
-
poolOptions.softIdleTimeoutMillis
|
|
130
|
+
(_g = poolOptions.softIdleTimeoutMillis) !== null && _g !== void 0 ? _g : (poolOptions.softIdleTimeoutMillis = queue_idle);
|
|
129
131
|
}
|
|
130
132
|
if (timeout > 0) {
|
|
131
|
-
poolOptions.acquireTimeoutMillis
|
|
133
|
+
(_h = poolOptions.acquireTimeoutMillis) !== null && _h !== void 0 ? _h : (poolOptions.acquireTimeoutMillis = timeout);
|
|
132
134
|
}
|
|
133
135
|
}
|
|
134
136
|
const poolKey = getPoolKey(client);
|
|
@@ -152,6 +154,7 @@ async function executeQuery(item, options) {
|
|
|
152
154
|
}
|
|
153
155
|
exports.executeQuery = executeQuery;
|
|
154
156
|
async function executeBatchQuery(batch, options = '', outResult) {
|
|
157
|
+
var _a, _b, _c;
|
|
155
158
|
const length = batch.length;
|
|
156
159
|
if (length === 0) {
|
|
157
160
|
return [];
|
|
@@ -179,7 +182,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
179
182
|
const caching = this.hasCache("redis", sessionKey);
|
|
180
183
|
const tasks = new Array(length);
|
|
181
184
|
const clients = [];
|
|
182
|
-
let redisClient, redisCredential, redisCache = 0, onceCredential = connectOnce ? batch[0].options
|
|
185
|
+
let redisClient, redisCredential, redisCache = 0, onceCredential = connectOnce ? (_a = batch[0].options) === null || _a === void 0 ? void 0 : _a.client : undefined;
|
|
183
186
|
const getConnection = async (item, credential) => {
|
|
184
187
|
item.transactionState = 64;
|
|
185
188
|
let client;
|
|
@@ -207,7 +210,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
207
210
|
item.transactionState &= ~64;
|
|
208
211
|
return client;
|
|
209
212
|
};
|
|
210
|
-
if (this.host
|
|
213
|
+
if ((_b = this.host) === null || _b === void 0 ? void 0 : _b.username) {
|
|
211
214
|
this.applyCommand(...batch);
|
|
212
215
|
}
|
|
213
216
|
for (let i = 0; i < length; ++i) {
|
|
@@ -233,7 +236,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
233
236
|
}
|
|
234
237
|
item.transactionState = 1;
|
|
235
238
|
const command = (0, types_1.isPlainObject)(clientOptions.command) ? redis.commandOptions(clientOptions.command) : null;
|
|
236
|
-
const uuidKey = (credential.uuidKey || (credential.uuidKey = (onceCredential ? batch[0] : item).credential
|
|
239
|
+
const uuidKey = (credential.uuidKey || (credential.uuidKey = (_c = (onceCredential ? batch[0] : item).credential) === null || _c === void 0 ? void 0 : _c.uuidKey));
|
|
237
240
|
const targetObject = typeof checkObject === 'string' ? this.hasCoerce("redis", 'options', uuidKey) && (0, types_1.asFunction)(checkObject) : checkObject;
|
|
238
241
|
const cacheValue = ignoreCache === undefined ? sessionKey : Array.isArray(ignoreCache) ? { sessionKey, exclusiveOf: ignoreCache } : { sessionKey, renewCache: ignoreCache === 0 };
|
|
239
242
|
let queryString = '', rows;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/redis",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"description": "Redis client driver for E-mc.",
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"types": "client/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@e-mc/db": "^0.8.
|
|
25
|
-
"@e-mc/types": "^0.8.
|
|
26
|
-
"redis": "^4.6.
|
|
24
|
+
"@e-mc/db": "^0.8.14",
|
|
25
|
+
"@e-mc/types": "^0.8.14",
|
|
26
|
+
"redis": "^4.6.15"
|
|
27
27
|
}
|
|
28
28
|
}
|