You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-01 16:46:54 +03:00
V5 bringing RESP3, Sentinel and TypeMapping to node-redis
RESP3 Support - Some commands responses in RESP3 aren't stable yet and therefore return an "untyped" ReplyUnion. Sentinel TypeMapping Correctly types Multi commands Note: some API changes to be further documented in v4-to-v5.md
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
import yargs from 'yargs';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
import { promises as fs } from 'fs';
|
||||
import { fork } from 'child_process';
|
||||
import { URL, fileURLToPath } from 'url';
|
||||
import { once } from 'events';
|
||||
import { extname } from 'path';
|
||||
import { promises as fs } from 'node:fs';
|
||||
import { fork } from 'node:child_process';
|
||||
import { URL, fileURLToPath } from 'node:url';
|
||||
import { once } from 'node:events';
|
||||
import { extname } from 'node:path';
|
||||
|
||||
async function getPathChoices() {
|
||||
const dirents = await fs.readdir(new URL('.', import.meta.url), {
|
||||
|
20
benchmark/lib/ping/ioredis-auto-pipeline.js
Normal file
20
benchmark/lib/ping/ioredis-auto-pipeline.js
Normal file
@ -0,0 +1,20 @@
|
||||
import Redis from 'ioredis';
|
||||
|
||||
export default async (host) => {
|
||||
const client = new Redis({
|
||||
host,
|
||||
lazyConnect: true,
|
||||
enableAutoPipelining: true
|
||||
});
|
||||
|
||||
await client.connect();
|
||||
|
||||
return {
|
||||
benchmark() {
|
||||
return client.ping();
|
||||
},
|
||||
teardown() {
|
||||
return client.disconnect();
|
||||
}
|
||||
}
|
||||
};
|
21
benchmark/lib/ping/local-resp2.js
Normal file
21
benchmark/lib/ping/local-resp2.js
Normal file
@ -0,0 +1,21 @@
|
||||
import { createClient } from 'redis-local';
|
||||
|
||||
export default async (host) => {
|
||||
const client = createClient({
|
||||
socket: {
|
||||
host
|
||||
},
|
||||
RESP: 2
|
||||
});
|
||||
|
||||
await client.connect();
|
||||
|
||||
return {
|
||||
benchmark() {
|
||||
return client.ping();
|
||||
},
|
||||
teardown() {
|
||||
return client.disconnect();
|
||||
}
|
||||
};
|
||||
};
|
23
benchmark/lib/ping/local-resp3-buffer-proxy.js
Normal file
23
benchmark/lib/ping/local-resp3-buffer-proxy.js
Normal file
@ -0,0 +1,23 @@
|
||||
import { createClient, RESP_TYPES } from 'redis-local';
|
||||
|
||||
export default async (host) => {
|
||||
const client = createClient({
|
||||
socket: {
|
||||
host
|
||||
},
|
||||
RESP: 3
|
||||
}).withTypeMapping({
|
||||
[RESP_TYPES.SIMPLE_STRING]: Buffer
|
||||
});
|
||||
|
||||
await client.connect();
|
||||
|
||||
return {
|
||||
benchmark() {
|
||||
return client.ping();
|
||||
},
|
||||
teardown() {
|
||||
return client.disconnect();
|
||||
}
|
||||
};
|
||||
};
|
24
benchmark/lib/ping/local-resp3-buffer.js
Normal file
24
benchmark/lib/ping/local-resp3-buffer.js
Normal file
@ -0,0 +1,24 @@
|
||||
import { createClient, RESP_TYPES } from 'redis-local';
|
||||
|
||||
export default async (host) => {
|
||||
const client = createClient({
|
||||
socket: {
|
||||
host
|
||||
},
|
||||
commandOptions: {
|
||||
[RESP_TYPES.SIMPLE_STRING]: Buffer
|
||||
},
|
||||
RESP: 3
|
||||
});
|
||||
|
||||
await client.connect();
|
||||
|
||||
return {
|
||||
benchmark() {
|
||||
return client.ping();
|
||||
},
|
||||
teardown() {
|
||||
return client.disconnect();
|
||||
}
|
||||
};
|
||||
};
|
27
benchmark/lib/ping/local-resp3-module-with-flags.js
Normal file
27
benchmark/lib/ping/local-resp3-module-with-flags.js
Normal file
@ -0,0 +1,27 @@
|
||||
import { createClient } from 'redis-local';
|
||||
import PING from 'redis-local/dist/lib/commands/PING.js';
|
||||
|
||||
export default async (host) => {
|
||||
const client = createClient({
|
||||
socket: {
|
||||
host
|
||||
},
|
||||
RESP: 3,
|
||||
modules: {
|
||||
module: {
|
||||
ping: PING.default
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await client.connect();
|
||||
|
||||
return {
|
||||
benchmark() {
|
||||
return client.withTypeMapping({}).module.ping();
|
||||
},
|
||||
teardown() {
|
||||
return client.disconnect();
|
||||
}
|
||||
};
|
||||
};
|
27
benchmark/lib/ping/local-resp3-module.js
Normal file
27
benchmark/lib/ping/local-resp3-module.js
Normal file
@ -0,0 +1,27 @@
|
||||
import { createClient } from 'redis-local';
|
||||
import PING from 'redis-local/dist/lib/commands/PING.js';
|
||||
|
||||
export default async (host) => {
|
||||
const client = createClient({
|
||||
socket: {
|
||||
host
|
||||
},
|
||||
RESP: 3,
|
||||
modules: {
|
||||
module: {
|
||||
ping: PING.default
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await client.connect();
|
||||
|
||||
return {
|
||||
benchmark() {
|
||||
return client.module.ping();
|
||||
},
|
||||
teardown() {
|
||||
return client.disconnect();
|
||||
}
|
||||
};
|
||||
};
|
21
benchmark/lib/ping/local-resp3.js
Normal file
21
benchmark/lib/ping/local-resp3.js
Normal file
@ -0,0 +1,21 @@
|
||||
import { createClient } from 'redis-local';
|
||||
|
||||
export default async (host) => {
|
||||
const client = createClient({
|
||||
socket: {
|
||||
host
|
||||
},
|
||||
RESP: 3
|
||||
});
|
||||
|
||||
await client.connect();
|
||||
|
||||
return {
|
||||
benchmark() {
|
||||
return client.ping();
|
||||
},
|
||||
teardown() {
|
||||
return client.disconnect();
|
||||
}
|
||||
};
|
||||
};
|
@ -1,6 +1,6 @@
|
||||
import { createClient } from 'redis-v3';
|
||||
import { once } from 'events';
|
||||
import { promisify } from 'util';
|
||||
import { once } from 'node:events';
|
||||
import { promisify } from 'node:util';
|
||||
|
||||
export default async (host) => {
|
||||
const client = createClient({ host }),
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { createClient } from '@redis/client';
|
||||
import { createClient } from 'redis-v4';
|
||||
|
||||
export default async (host) => {
|
||||
const client = createClient({
|
||||
|
@ -1,7 +1,7 @@
|
||||
import yargs from 'yargs';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
import { basename } from 'path';
|
||||
import { promises as fs } from 'fs';
|
||||
import { basename } from 'node:path';
|
||||
import { promises as fs } from 'node:fs';
|
||||
import * as hdr from 'hdr-histogram-js';
|
||||
hdr.initWebAssemblySync();
|
||||
|
||||
@ -71,7 +71,7 @@ const benchmarkStart = process.hrtime.bigint(),
|
||||
histogram = await run(times),
|
||||
benchmarkNanoseconds = process.hrtime.bigint() - benchmarkStart,
|
||||
json = {
|
||||
timestamp,
|
||||
// timestamp,
|
||||
operationsPerSecond: times / Number(benchmarkNanoseconds) * 1_000_000_000,
|
||||
p0: histogram.getValueAtPercentile(0),
|
||||
p50: histogram.getValueAtPercentile(50),
|
||||
|
@ -1,6 +1,6 @@
|
||||
import yargs from 'yargs';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
import { randomBytes } from 'crypto';
|
||||
import { randomBytes } from 'node:crypto';
|
||||
|
||||
const { size } = yargs(hideBin(process.argv))
|
||||
.option('size', {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { createClient } from 'redis-v3';
|
||||
import { once } from 'events';
|
||||
import { promisify } from 'util';
|
||||
import { once } from 'node:events';
|
||||
import { promisify } from 'node:util';
|
||||
|
||||
export default async (host, { randomString }) => {
|
||||
const client = createClient({ host }),
|
||||
|
87
benchmark/package-lock.json
generated
87
benchmark/package-lock.json
generated
@ -6,11 +6,12 @@
|
||||
"": {
|
||||
"name": "@redis/client-benchmark",
|
||||
"dependencies": {
|
||||
"@redis/client": "../packages/client",
|
||||
"hdr-histogram-js": "3.0.0",
|
||||
"ioredis": "5.3.2",
|
||||
"redis-v3": "npm:redis@3.1.2",
|
||||
"yargs": "17.7.2"
|
||||
"ioredis": "5",
|
||||
"redis-local": "file:../packages/client",
|
||||
"redis-v3": "npm:redis@3",
|
||||
"redis-v4": "npm:redis@4",
|
||||
"yargs": "17.7.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@assemblyscript/loader": {
|
||||
@ -23,10 +24,18 @@
|
||||
"resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz",
|
||||
"integrity": "sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg=="
|
||||
},
|
||||
"node_modules/@redis/bloom": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-1.2.0.tgz",
|
||||
"integrity": "sha512-HG2DFjYKbpNmVXsa0keLHp/3leGJz1mjh09f2RLGGLQZzSHpkmZWuwJbAvo3QcRY8p80m5+ZdXZdYOSBLlp7Cg==",
|
||||
"peerDependencies": {
|
||||
"@redis/client": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@redis/client": {
|
||||
"version": "1.5.7",
|
||||
"resolved": "file:../packages/client",
|
||||
"license": "MIT",
|
||||
"resolved": "https://registry.npmjs.org/@redis/client/-/client-1.5.7.tgz",
|
||||
"integrity": "sha512-gaOBOuJPjK5fGtxSseaKgSvjiZXQCdLlGg9WYQst+/GRUjmXaiB5kVkeQMRtPc7Q2t93XZcJfBMSwzs/XS9UZw==",
|
||||
"dependencies": {
|
||||
"cluster-key-slot": "1.1.2",
|
||||
"generic-pool": "3.9.0",
|
||||
@ -36,6 +45,38 @@
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/@redis/graph": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@redis/graph/-/graph-1.1.0.tgz",
|
||||
"integrity": "sha512-16yZWngxyXPd+MJxeSr0dqh2AIOi8j9yXKcKCwVaKDbH3HTuETpDVPcLujhFYVPtYrngSco31BUcSa9TH31Gqg==",
|
||||
"peerDependencies": {
|
||||
"@redis/client": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@redis/json": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@redis/json/-/json-1.0.4.tgz",
|
||||
"integrity": "sha512-LUZE2Gdrhg0Rx7AN+cZkb1e6HjoSKaeeW8rYnt89Tly13GBI5eP4CwDVr+MY8BAYfCg4/N15OUrtLoona9uSgw==",
|
||||
"peerDependencies": {
|
||||
"@redis/client": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@redis/search": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@redis/search/-/search-1.1.2.tgz",
|
||||
"integrity": "sha512-/cMfstG/fOh/SsE+4/BQGeuH/JJloeWuH+qJzM8dbxuWvdWibWAOAHHCZTMPhV3xIlH4/cUEIA8OV5QnYpaVoA==",
|
||||
"peerDependencies": {
|
||||
"@redis/client": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@redis/time-series": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@redis/time-series/-/time-series-1.0.4.tgz",
|
||||
"integrity": "sha512-ThUIgo2U/g7cCuZavucQTQzA9g9JbDDY2f64u3AbAoz/8vE2lt2U37LamDUVChhaDA3IRT9R6VvJwqnUfTJzng==",
|
||||
"peerDependencies": {
|
||||
"@redis/client": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ansi-regex": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||
@ -244,6 +285,20 @@
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/redis-local": {
|
||||
"name": "@redis/client",
|
||||
"version": "1.5.6",
|
||||
"resolved": "file:../packages/client",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cluster-key-slot": "1.1.2",
|
||||
"generic-pool": "3.9.0",
|
||||
"yallist": "4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/redis-parser": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz",
|
||||
@ -282,6 +337,20 @@
|
||||
"node": ">=0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/redis-v4": {
|
||||
"name": "redis",
|
||||
"version": "4.6.6",
|
||||
"resolved": "https://registry.npmjs.org/redis/-/redis-4.6.6.tgz",
|
||||
"integrity": "sha512-aLs2fuBFV/VJ28oLBqYykfnhGGkFxvx0HdCEBYdJ99FFbSEMZ7c1nVKwR6ZRv+7bb7JnC0mmCzaqu8frgOYhpA==",
|
||||
"dependencies": {
|
||||
"@redis/bloom": "1.2.0",
|
||||
"@redis/client": "1.5.7",
|
||||
"@redis/graph": "1.1.0",
|
||||
"@redis/json": "1.0.4",
|
||||
"@redis/search": "1.1.2",
|
||||
"@redis/time-series": "1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/require-directory": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
||||
@ -349,9 +418,9 @@
|
||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
|
||||
},
|
||||
"node_modules/yargs": {
|
||||
"version": "17.7.2",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",
|
||||
"integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",
|
||||
"version": "17.7.1",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.1.tgz",
|
||||
"integrity": "sha512-cwiTb08Xuv5fqF4AovYacTFNxk62th7LKJ6BL9IGUpTJrWoU7/7WdQGTP2SjKf1dUNBGzDd28p/Yfs/GI6JrLw==",
|
||||
"dependencies": {
|
||||
"cliui": "^8.0.1",
|
||||
"escalade": "^3.1.1",
|
||||
|
@ -7,10 +7,11 @@
|
||||
"start": "node ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@redis/client": "../packages/client",
|
||||
"hdr-histogram-js": "3.0.0",
|
||||
"ioredis": "5.3.2",
|
||||
"redis-v3": "npm:redis@3.1.2",
|
||||
"yargs": "17.7.2"
|
||||
"ioredis": "5",
|
||||
"redis-local": "file:../packages/client",
|
||||
"redis-v3": "npm:redis@3",
|
||||
"redis-v4": "npm:redis@4",
|
||||
"yargs": "17.7.1"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user