@pi-r/redis 0.8.5 → 0.8.6
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 +12 -14
- package/package.json +3 -3
package/client/index.js
CHANGED
|
@@ -202,7 +202,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
202
202
|
}
|
|
203
203
|
for (let i = 0; i < length; ++i) {
|
|
204
204
|
const item = batch[i];
|
|
205
|
-
const { source, uri, key,
|
|
205
|
+
const { source, uri, key, search, aggregate, update, options: clientOptions = {}, ignoreCache } = item;
|
|
206
206
|
let credential = (redisCredential || onceCredential), error;
|
|
207
207
|
if (!credential && !(0, types_1.isPlainObject)(credential = clientOptions.client) && (error = (0, types_1.errorMessage)(source, "Invalid credentials")) || !((0, types_1.isString)(key) || (0, types_1.isArray)(key) || (0, types_1.isPlainObject)(search) && ((0, types_1.isPlainObject)(search.schema) || (0, types_1.isString)(search.query)) || (0, types_1.isPlainObject)(aggregate) && ((0, types_1.isPlainObject)(aggregate.schema) || (0, types_1.isString)(aggregate.query))) && (error = (0, types_1.errorMessage)(source, "Missing database query", uri))) {
|
|
208
208
|
++redisCache;
|
|
@@ -226,6 +226,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
226
226
|
const uuidKey = (credential.uuidKey ||= (onceCredential ? batch[0] : item).credential?.uuidKey);
|
|
227
227
|
const targetObject = typeof checkObject === 'string' ? this.hasCoerce("redis", 'options', uuidKey) && (0, types_1.asFunction)(checkObject) : checkObject;
|
|
228
228
|
const cacheValue = ignoreCache === undefined ? sessionKey : Array.isArray(ignoreCache) ? { sessionKey, exclusiveOf: ignoreCache } : { sessionKey, renewCache: ignoreCache === 0 };
|
|
229
|
+
const format = (key ? item.format?.toUpperCase() || 'HASH' : undefined);
|
|
229
230
|
let queryString = '', rows;
|
|
230
231
|
if (caching && ignoreCache !== true) {
|
|
231
232
|
if ((0, types_1.isObject)(search)) {
|
|
@@ -234,17 +235,14 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
234
235
|
else if ((0, types_1.isObject)(aggregate)) {
|
|
235
236
|
queryString = Db.asString(aggregate, true);
|
|
236
237
|
}
|
|
237
|
-
else if (
|
|
238
|
-
queryString = Db.asString(key, true);
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
if (queryString) {
|
|
244
|
-
queryString += '_' + format;
|
|
238
|
+
else if (key) {
|
|
239
|
+
queryString = Db.asString(key, true) + '_' + format;
|
|
240
|
+
if (targetObject && typeof item.cacheObjectKey === 'string') {
|
|
241
|
+
queryString += '_' + targetObject.toString() + item.cacheObjectKey;
|
|
242
|
+
}
|
|
245
243
|
}
|
|
246
|
-
if (ignoreCache !== 1) {
|
|
247
|
-
if (rows = this.getQueryResult(source, DbPool.sanitize(credential), queryString, cacheValue)) {
|
|
244
|
+
if (ignoreCache !== 1 && !update) {
|
|
245
|
+
if (rows = this.getQueryResult(source, DbPool.sanitize(redisCredential || credential), queryString, cacheValue)) {
|
|
248
246
|
++redisCache;
|
|
249
247
|
if (parallel) {
|
|
250
248
|
tasks[i] = Promise.resolve(rows);
|
|
@@ -444,7 +442,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
444
442
|
}
|
|
445
443
|
if (pending) {
|
|
446
444
|
pending.then(async (code) => {
|
|
447
|
-
if (code === undefined || code === null ||
|
|
445
|
+
if (code === undefined || code === null || (0, types_1.isString)(code) && code !== 'OK' && codeMin !== -Infinity || typeof code === 'number' && code <= codeMin || Array.isArray(code) && code.every(resp => resp === null || typeof resp === 'number' && resp <= codeMin)) {
|
|
448
446
|
failValue();
|
|
449
447
|
return;
|
|
450
448
|
}
|
|
@@ -551,7 +549,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
551
549
|
else if (key) {
|
|
552
550
|
let data;
|
|
553
551
|
if (Array.isArray(key)) {
|
|
554
|
-
switch (format
|
|
552
|
+
switch (format) {
|
|
555
553
|
case 'HKEYS':
|
|
556
554
|
data = await Promise.all(key.map(async (k) => client.hKeys(...command ? [command, k] : [k])));
|
|
557
555
|
break;
|
|
@@ -570,7 +568,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
570
568
|
}
|
|
571
569
|
}
|
|
572
570
|
else {
|
|
573
|
-
switch (format
|
|
571
|
+
switch (format) {
|
|
574
572
|
case 'HKEYS':
|
|
575
573
|
data = await client.hKeys(...command ? [command, key] : [key]);
|
|
576
574
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/redis",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
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.10.
|
|
25
|
-
"@e-mc/types": "^0.10.
|
|
24
|
+
"@e-mc/db": "^0.10.21",
|
|
25
|
+
"@e-mc/types": "^0.10.21",
|
|
26
26
|
"redis": "^4.7.0"
|
|
27
27
|
}
|
|
28
28
|
}
|