You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-12-25 00:40:59 +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 }),
|
||||
|
||||
Reference in New Issue
Block a user