@pi-r/redis 0.2.8 → 0.3.2
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/LICENSE +1 -1
- package/README.md +1 -1
- package/client/index.d.ts +2 -2
- package/client/index.js +8 -9
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright 2023
|
|
1
|
+
Copyright 2023 Studio Trigger
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
package/client/index.d.ts
CHANGED
package/client/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DB_SOURCE_TYPE = exports.DB_SOURCE_CLIENT = exports.checkTimeout = exports.executeBatchQuery = exports.executeQuery = exports.setCredential = void 0;
|
|
4
|
+
const redis = require("redis");
|
|
4
5
|
const util_1 = require("@e-mc/db/util");
|
|
5
6
|
const types_1 = require("@e-mc/types");
|
|
6
7
|
const Db = require("@e-mc/db");
|
|
@@ -105,7 +106,6 @@ async function setCredential(item) {
|
|
|
105
106
|
}
|
|
106
107
|
const poolKey = getPoolKey(client);
|
|
107
108
|
if (!(pool = POOL_STATE[poolKey]) || pool.closed) {
|
|
108
|
-
const db = require("redis");
|
|
109
109
|
const config = this.getPoolConfig("redis", password);
|
|
110
110
|
const poolOptions = client.isolationPoolOptions || (client.isolationPoolOptions = {});
|
|
111
111
|
if (config) {
|
|
@@ -127,9 +127,9 @@ async function setCredential(item) {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
try {
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
const target = new RedisPool(await getClient(redis, client, poolKey), poolKey, username && password ? { username, password } : undefined).add(item);
|
|
131
|
+
target.parent = POOL_STATE;
|
|
132
|
+
target.success = 1;
|
|
133
133
|
}
|
|
134
134
|
catch {
|
|
135
135
|
item.usePool = false;
|
|
@@ -151,7 +151,6 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
151
151
|
if (length === 0) {
|
|
152
152
|
return [];
|
|
153
153
|
}
|
|
154
|
-
const db = require("redis");
|
|
155
154
|
let parallel, checkObject, connectOnce, errorQuery, sessionKey, outCacheMiss;
|
|
156
155
|
if ((0, types_1.isPlainObject)(options)) {
|
|
157
156
|
({ parallel, checkObject, connectOnce, errorQuery, sessionKey, outCacheMiss } = options);
|
|
@@ -193,7 +192,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
193
192
|
(credential.isolationPoolOptions || (credential.isolationPoolOptions = {})).max = size;
|
|
194
193
|
}
|
|
195
194
|
}
|
|
196
|
-
clients.push(client = await getClient(
|
|
195
|
+
clients.push(client = await getClient(redis, credential));
|
|
197
196
|
}
|
|
198
197
|
if (connectOnce) {
|
|
199
198
|
redisClient = client;
|
|
@@ -228,7 +227,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
228
227
|
const targetObject = typeof checkObject === 'string' ? this.hasCoerce("redis", 'options', uuidKey) && (0, types_1.asFunction)(checkObject) : checkObject;
|
|
229
228
|
const renewCache = ignoreCache === 0;
|
|
230
229
|
const cacheValue = renewCache ? { sessionKey, renewCache } : sessionKey;
|
|
231
|
-
const command = (0, types_1.isPlainObject)(clientOptions.command) ?
|
|
230
|
+
const command = (0, types_1.isPlainObject)(clientOptions.command) ? redis.commandOptions(clientOptions.command) : null;
|
|
232
231
|
let queryString = '', rows;
|
|
233
232
|
if (caching && ignoreCache !== true || ignoreCache === false || ignoreCache === 1 || renewCache) {
|
|
234
233
|
if ((0, types_1.isObject)(search)) {
|
|
@@ -290,7 +289,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
290
289
|
}
|
|
291
290
|
const failKey = () => failed((0, types_1.errorMessage)(f, "Invalid key", Db.asString(k) || "Unknown"));
|
|
292
291
|
const failValue = () => failed((0, types_1.errorMessage)(f, "Invalid value", Db.asString(v) || "Unknown"));
|
|
293
|
-
const commandSet = (0, types_1.isPlainObject)(setOptions.command) &&
|
|
292
|
+
const commandSet = (0, types_1.isPlainObject)(setOptions.command) && redis.commandOptions(setOptions.command);
|
|
294
293
|
let pending;
|
|
295
294
|
if ((f = f.toUpperCase()) === 'JSON') {
|
|
296
295
|
if (typeof k !== 'string') {
|
|
@@ -451,7 +450,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
451
450
|
try {
|
|
452
451
|
if (target === search) {
|
|
453
452
|
const reply = await (command ? client.ft.search(command, index || idx, query, clientOptions.search) : client.ft.search(index || idx, query, clientOptions.search));
|
|
454
|
-
rows = reply.documents.map(doc => (doc.value
|
|
453
|
+
rows = reply.documents.map(doc => (doc.value.__id__ = doc.id) && doc.value);
|
|
455
454
|
}
|
|
456
455
|
else {
|
|
457
456
|
({ results: rows } = await (command ? client.ft.aggregate(command, index || idx, query, clientOptions.aggregate) : client.ft.aggregate(index || idx, query, clientOptions.aggregate)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/redis",
|
|
3
|
-
"version": "0.2
|
|
3
|
+
"version": "0.3.2",
|
|
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.
|
|
25
|
-
"@e-mc/types": "^0.
|
|
24
|
+
"@e-mc/db": "^0.6.1",
|
|
25
|
+
"@e-mc/types": "^0.6.1",
|
|
26
26
|
"redis": "^4.6.13"
|
|
27
27
|
}
|
|
28
28
|
}
|