1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00
This commit is contained in:
Leibale
2023-06-19 18:04:31 -04:00
parent 9c1f2a0f86
commit f150e86f95
47 changed files with 2490 additions and 1798 deletions

View File

@@ -285,9 +285,10 @@ export default class RedisCommandsQueue {
} }
private _flushWaitingForReply(err: Error): void { private _flushWaitingForReply(err: Error): void {
while (this._waitingForReply.head) { for (const node of this._waitingForReply) {
this._waitingForReply.shift()!.reject(err); node.reject(err);
} }
this._waitingForReply.reset();
} }
private static _removeAbortListener(command: CommandWaitingToBeSent) { private static _removeAbortListener(command: CommandWaitingToBeSent) {
@@ -324,12 +325,10 @@ export default class RedisCommandsQueue {
this.decoder.reset(); this.decoder.reset();
this._pubSub.reset(); this._pubSub.reset();
this._flushWaitingForReply(err); this._flushWaitingForReply(err);
while (this._waitingToBeSent.head) { for (const node of this._waitingToBeSent) {
RedisCommandsQueue._flushWaitingToBeSent( RedisCommandsQueue._flushWaitingToBeSent(node, err);
this._waitingToBeSent.shift()!,
err
);
} }
this._waitingToBeSent.reset();
} }
isEmpty() { isEmpty() {

View File

@@ -3,12 +3,14 @@ import testUtils, { GLOBAL, waitTillBeenCalled } from '../test-utils';
import RedisClient, { RedisClientType } from '.'; import RedisClient, { RedisClientType } from '.';
// import { RedisClientMultiCommandType } from './multi-command'; // import { RedisClientMultiCommandType } from './multi-command';
// import { RedisCommandRawReply, RedisModules, RedisFunctions, RedisScripts } from '../commands'; // import { RedisCommandRawReply, RedisModules, RedisFunctions, RedisScripts } from '../commands';
// import { AbortError, ClientClosedError, ClientOfflineError, ConnectionTimeoutError, DisconnectsClientError, SocketClosedUnexpectedlyError, WatchError } from '../errors'; import { AbortError, ClientClosedError, ClientOfflineError, ConnectionTimeoutError, DisconnectsClientError, SocketClosedUnexpectedlyError, WatchError } from '../errors';
import { defineScript } from '../lua-script'; import { defineScript } from '../lua-script';
// import { spy } from 'sinon'; // import { spy } from 'sinon';
// import { once } from 'events'; import { once } from 'events';
// import { ClientKillFilters } from '../commands/CLIENT_KILL'; // import { ClientKillFilters } from '../commands/CLIENT_KILL';
// import { promisify } from 'util'; // import { promisify } from 'util';
import { MATH_FUNCTION, loadMathFunction } from '../commands/FUNCTION_LOAD.spec';
import { RESP_TYPES } from '../RESP/decoder';
export const SQUARE_SCRIPT = defineScript({ export const SQUARE_SCRIPT = defineScript({
SCRIPT: 'return ARGV[1] * ARGV[1];', SCRIPT: 'return ARGV[1] * ARGV[1];',
@@ -113,362 +115,116 @@ describe('Client', () => {
} }
}); });
// describe('legacyMode', () => { testUtils.testWithClient('connect, ready and end events', async client => {
// testUtils.testWithClient('client.sendCommand should call the callback', async client => { await Promise.all([
// assert.equal( once(client, 'connect'),
// await promisify(client.sendCommand).call(client, 'PING'), once(client, 'ready'),
// 'PONG' client.connect()
// ); ]);
// }, {
// ...GLOBAL.SERVERS.OPEN,
// clientOptions: {
// legacyMode: true
// }
// });
// testUtils.testWithClient('client.sendCommand should work without callback', async client => { const promise = once(client, 'end');
// client.sendCommand(['PING']); console.log('listen to end', client.listeners('end'));
// await client.v4.ping(); // make sure the first command was replied client.close();
// }, { await promise;
// ...GLOBAL.SERVERS.OPEN, }, {
// clientOptions: { ...GLOBAL.SERVERS.OPEN,
// legacyMode: true disableClientSetup: true
// } });
// });
// testUtils.testWithClient('client.sendCommand should reply with error', async client => { describe('sendCommand', () => {
// await assert.rejects( testUtils.testWithClient('PING', async client => {
// promisify(client.sendCommand).call(client, '1', '2') assert.equal(await client.sendCommand(['PING']), 'PONG');
// ); }, GLOBAL.SERVERS.OPEN);
// }, {
// ...GLOBAL.SERVERS.OPEN,
// clientOptions: {
// legacyMode: true
// }
// });
// testUtils.testWithClient('client.hGetAll should reply with error', async client => { describe('AbortController', () => {
// await assert.rejects( before(function () {
// promisify(client.hGetAll).call(client) if (!global.AbortController) {
// ); this.skip();
// }, { }
// ...GLOBAL.SERVERS.OPEN, });
// clientOptions: {
// legacyMode: true
// }
// });
// testUtils.testWithClient('client.v4.sendCommand should return a promise', async client => { testUtils.testWithClient('success', async client => {
// assert.equal( await client.sendCommand(['PING'], {
// await client.v4.sendCommand(['PING']), abortSignal: new AbortController().signal
// 'PONG' });
// ); }, GLOBAL.SERVERS.OPEN);
// }, {
// ...GLOBAL.SERVERS.OPEN,
// clientOptions: {
// legacyMode: true
// }
// });
// testUtils.testWithClient('client.v4.{command} should return a promise', async client => { testUtils.testWithClient('AbortError', client => {
// assert.equal( const controller = new AbortController();
// await client.v4.ping(), controller.abort();
// 'PONG'
// );
// }, {
// ...GLOBAL.SERVERS.OPEN,
// clientOptions: {
// legacyMode: true
// }
// });
// testUtils.testWithClient('client.{command} should accept vardict arguments', async client => { return assert.rejects(
// assert.equal( client.sendCommand(['PING'], {
// await promisify(client.set).call(client, 'a', 'b'), abortSignal: controller.signal
// 'OK' }),
// ); AbortError
// }, { );
// ...GLOBAL.SERVERS.OPEN, }, GLOBAL.SERVERS.OPEN);
// clientOptions: { });
// legacyMode: true
// }
// });
// testUtils.testWithClient('client.{command} should accept arguments array', async client => { testUtils.testWithClient('undefined and null should not break the client', async client => {
// assert.equal( await assert.rejects(
// await promisify(client.set).call(client, ['a', 'b']), client.sendCommand([null as any, undefined as any]),
// 'OK' TypeError
// ); );
// }, {
// ...GLOBAL.SERVERS.OPEN,
// clientOptions: {
// legacyMode: true
// }
// });
// testUtils.testWithClient('client.{command} should accept mix of arrays and arguments', async client => { assert.equal(
// assert.equal( await client.ping(),
// await promisify(client.set).call(client, ['a'], 'b', ['EX', 1]), 'PONG'
// 'OK' );
// ); }, GLOBAL.SERVERS.OPEN);
// }, { });
// ...GLOBAL.SERVERS.OPEN,
// clientOptions: {
// legacyMode: true
// }
// });
// testUtils.testWithClient('client.hGetAll should return object', async client => { describe('multi', () => {
// await client.v4.hSet('key', 'field', 'value'); testUtils.testWithClient('simple', async client => {
assert.deepEqual(
await client.multi()
.ping()
.set('key', 'value')
.get('key')
.exec(),
['PONG', 'OK', 'value']
);
}, GLOBAL.SERVERS.OPEN);
// assert.deepEqual( testUtils.testWithClient('should reject the whole chain on error', client => {
// await promisify(client.hGetAll).call(client, 'key'), return assert.rejects(
// Object.create(null, { client.multi()
// field: { .ping()
// value: 'value', .addCommand(['INVALID COMMAND'])
// configurable: true, .ping()
// enumerable: true .exec()
// } );
// }) }, GLOBAL.SERVERS.OPEN);
// );
// }, {
// ...GLOBAL.SERVERS.OPEN,
// clientOptions: {
// legacyMode: true
// }
// });
// function multiExecAsync< testUtils.testWithClient('should reject the whole chain upon client disconnect', async client => {
// M extends RedisModules, await client.close();
// F extends RedisFunctions,
// S extends RedisScripts
// >(multi: RedisClientMultiCommandType<M, F, S>): Promise<Array<RedisCommandRawReply>> {
// return new Promise((resolve, reject) => {
// (multi as any).exec((err: Error | undefined, replies: Array<RedisCommandRawReply>) => {
// if (err) return reject(err);
// resolve(replies); return assert.rejects(
// }); client.multi()
// }); .ping()
// } .set('key', 'value')
.get('key')
.exec(),
ClientClosedError
);
}, GLOBAL.SERVERS.OPEN);
// testUtils.testWithClient('client.multi.ping.exec should call the callback', async client => { testUtils.testWithClient('with script', async client => {
// assert.deepEqual( assert.deepEqual(
// await multiExecAsync( await client.multi()
// client.multi().ping() .square(2)
// ), .exec(),
// ['PONG'] [4]
// ); );
// }, { }, {
// ...GLOBAL.SERVERS.OPEN, ...GLOBAL.SERVERS.OPEN,
// clientOptions: { clientOptions: {
// legacyMode: true scripts: {
// } square: SQUARE_SCRIPT
// }); }
}
// testUtils.testWithClient('client.multi.ping.exec should call the callback', async client => { });
// client.multi()
// .ping()
// .exec();
// await client.v4.ping(); // make sure the first command was replied
// }, {
// ...GLOBAL.SERVERS.OPEN,
// clientOptions: {
// legacyMode: true
// }
// });
// testUtils.testWithClient('client.multi.ping.v4.ping.v4.exec should return a promise', async client => {
// assert.deepEqual(
// await client.multi()
// .ping()
// .v4.ping()
// .v4.exec(),
// ['PONG', 'PONG']
// );
// }, {
// ...GLOBAL.SERVERS.OPEN,
// clientOptions: {
// legacyMode: true
// }
// });
// testUtils.testWithClient('client.{script} should return a promise', async client => {
// assert.equal(
// await client.square(2),
// 4
// );
// }, {
// ...GLOBAL.SERVERS.OPEN,
// clientOptions: {
// legacyMode: true,
// scripts: {
// square: SQUARE_SCRIPT
// }
// }
// });
// testUtils.testWithClient('client.multi.{command}.exec should flatten array arguments', async client => {
// assert.deepEqual(
// await client.multi()
// .sAdd('a', ['b', 'c'])
// .v4.exec(),
// [2]
// );
// }, {
// ...GLOBAL.SERVERS.OPEN,
// clientOptions: {
// legacyMode: true
// }
// });
// testUtils.testWithClient('client.multi.hGetAll should return object', async client => {
// assert.deepEqual(
// await multiExecAsync(
// client.multi()
// .hSet('key', 'field', 'value')
// .hGetAll('key')
// ),
// [
// 1,
// Object.create(null, {
// field: {
// value: 'value',
// configurable: true,
// enumerable: true
// }
// })
// ]
// );
// }, {
// ...GLOBAL.SERVERS.OPEN,
// clientOptions: {
// legacyMode: true
// }
// });
// });
// describe('events', () => {
// testUtils.testWithClient('connect, ready, end', async client => {
// await Promise.all([
// once(client, 'connect'),
// once(client, 'ready'),
// client.connect()
// ]);
// await Promise.all([
// once(client, 'end'),
// client.disconnect()
// ]);
// }, {
// ...GLOBAL.SERVERS.OPEN,
// disableClientSetup: true
// });
// });
// describe('sendCommand', () => {
// testUtils.testWithClient('PING', async client => {
// assert.equal(await client.sendCommand(['PING']), 'PONG');
// }, GLOBAL.SERVERS.OPEN);
// testUtils.testWithClient('returnBuffers', async client => {
// assert.deepEqual(
// await client.sendCommand(['PING'], {
// returnBuffers: true
// }),
// Buffer.from('PONG')
// );
// }, GLOBAL.SERVERS.OPEN);
// describe('AbortController', () => {
// before(function () {
// if (!global.AbortController) {
// this.skip();
// }
// });
// testUtils.testWithClient('success', async client => {
// await client.sendCommand(['PING'], {
// signal: new AbortController().signal
// });
// }, GLOBAL.SERVERS.OPEN);
// testUtils.testWithClient('AbortError', client => {
// const controller = new AbortController();
// controller.abort();
// return assert.rejects(
// client.sendCommand(['PING'], {
// signal: controller.signal
// }),
// AbortError
// );
// }, GLOBAL.SERVERS.OPEN);
// });
// testUtils.testWithClient('undefined and null should not break the client', async client => {
// await assert.rejects(
// client.sendCommand([null as any, undefined as any]),
// TypeError
// );
// assert.equal(
// await client.ping(),
// 'PONG'
// );
// }, GLOBAL.SERVERS.OPEN);
// });
// describe('multi', () => {
// testUtils.testWithClient('simple', async client => {
// assert.deepEqual(
// await client.multi()
// .ping()
// .set('key', 'value')
// .get('key')
// .exec(),
// ['PONG', 'OK', 'value']
// );
// }, GLOBAL.SERVERS.OPEN);
// testUtils.testWithClient('should reject the whole chain on error', client => {
// return assert.rejects(
// client.multi()
// .ping()
// .addCommand(['INVALID COMMAND'])
// .ping()
// .exec()
// );
// }, GLOBAL.SERVERS.OPEN);
// testUtils.testWithClient('should reject the whole chain upon client disconnect', async client => {
// await client.disconnect();
// return assert.rejects(
// client.multi()
// .ping()
// .set('key', 'value')
// .get('key')
// .exec(),
// ClientClosedError
// );
// }, GLOBAL.SERVERS.OPEN);
// testUtils.testWithClient('with script', async client => {
// assert.deepEqual(
// await client.multi()
// .square(2)
// .exec(),
// [4]
// );
// }, {
// ...GLOBAL.SERVERS.OPEN,
// clientOptions: {
// scripts: {
// square: SQUARE_SCRIPT
// }
// }
// });
// testUtils.testWithClient('WatchError', async client => { // testUtils.testWithClient('WatchError', async client => {
// await client.watch('key'); // await client.watch('key');
@@ -489,23 +245,23 @@ describe('Client', () => {
// ); // );
// }, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
// describe('execAsPipeline', () => { describe('execAsPipeline', () => {
// testUtils.testWithClient('exec(true)', async client => { testUtils.testWithClient('exec(true)', async client => {
// assert.deepEqual( assert.deepEqual(
// await client.multi() await client.multi()
// .ping() .ping()
// .exec(true), .exec(true),
// ['PONG'] ['PONG']
// ); );
// }, GLOBAL.SERVERS.OPEN); }, GLOBAL.SERVERS.OPEN);
// testUtils.testWithClient('empty execAsPipeline', async client => { testUtils.testWithClient('empty execAsPipeline', async client => {
// assert.deepEqual( assert.deepEqual(
// await client.multi().execAsPipeline(), await client.multi().execAsPipeline(),
// [] []
// ); );
// }, GLOBAL.SERVERS.OPEN); }, GLOBAL.SERVERS.OPEN);
// }); });
// testUtils.testWithClient('should remember selected db', async client => { // testUtils.testWithClient('should remember selected db', async client => {
// await client.multi() // await client.multi()
@@ -520,63 +276,83 @@ describe('Client', () => {
// ...GLOBAL.SERVERS.OPEN, // ...GLOBAL.SERVERS.OPEN,
// minimumDockerVersion: [6, 2] // CLIENT INFO // minimumDockerVersion: [6, 2] // CLIENT INFO
// }); // });
// }); });
// testUtils.testWithClient('scripts', async client => { testUtils.testWithClient('scripts', async client => {
// assert.equal( assert.equal(
// await client.square(2), await client.square(2),
// 4 4
// ); );
// }, { }, {
// ...GLOBAL.SERVERS.OPEN, ...GLOBAL.SERVERS.OPEN,
// clientOptions: { clientOptions: {
// scripts: { scripts: {
// square: SQUARE_SCRIPT square: SQUARE_SCRIPT
// } }
// } }
// }); });
// const module = { const module = {
// echo: { echo: {
// transformArguments(message: string): Array<string> { transformArguments(message: string): Array<string> {
// return ['ECHO', message]; return ['ECHO', message];
// }, },
// transformReply(reply: string): string { transformReply(reply: string): string {
// return reply; return reply;
// } }
// } }
// }; };
// testUtils.testWithClient('modules', async client => { testUtils.testWithClient('modules', async client => {
// assert.equal( assert.equal(
// await client.module.echo('message'), await client.module.echo('message'),
// 'message' 'message'
// ); );
// }, { }, {
// ...GLOBAL.SERVERS.OPEN, ...GLOBAL.SERVERS.OPEN,
// clientOptions: { clientOptions: {
// modules: { modules: {
// module module
// } }
// } }
// }); });
// testUtils.testWithClient('functions', async client => { testUtils.testWithClient('functions', async client => {
// await loadMathFunction(client); await loadMathFunction(client);
// assert.equal( assert.equal(
// await client.math.square(2), await client.math.square(2),
// 4 4
// ); );
// }, { }, {
// ...GLOBAL.SERVERS.OPEN, ...GLOBAL.SERVERS.OPEN,
// minimumDockerVersion: [7, 0], minimumDockerVersion: [7, 0],
// clientOptions: { clientOptions: {
// functions: { functions: {
// math: MATH_FUNCTION.library math: MATH_FUNCTION.library
// } }
// } }
// }); });
testUtils.testWithClient('duplicate should reuse command options', async client => {
const duplicate = client.withTypeMapping({
[RESP_TYPES.SIMPLE_STRING]: Buffer
}).duplicate();
await duplicate.connect();
try {
assert.deepEqual(
await duplicate.ping(),
Buffer.from('PONG')
);
} finally {
duplicate.close();
}
}, {
...GLOBAL.SERVERS.OPEN,
disableClientSetup: true,
});
// describe('isolationPool', () => { // describe('isolationPool', () => {
// testUtils.testWithClient('executeIsolated', async client => { // testUtils.testWithClient('executeIsolated', async client => {

View File

@@ -68,7 +68,7 @@ export interface RedisClientOptions<
pingInterval?: number; pingInterval?: number;
} }
interface TypeMappingOption<TYPE_MAPPING extends TypeMapping> { export interface TypeMappingOption<TYPE_MAPPING extends TypeMapping> {
/** /**
* Maps bettwen RESP types to JavaScript types * Maps bettwen RESP types to JavaScript types
*/ */
@@ -532,11 +532,24 @@ export default class RedisClient<
// ); // );
// } // }
duplicate(overrides?: Partial<RedisClientOptions<M, F, S, RESP>>) { duplicate<
return new (Object.getPrototypeOf(this).constructor)({ _M extends RedisModules = M,
_F extends RedisFunctions = F,
_S extends RedisScripts = S,
_RESP extends RespVersions = RESP,
_TYPE_MAPPING extends TypeMapping = TYPE_MAPPING
>(overrides?: Partial<RedisClientOptions<_M, _F, _S, _RESP, _TYPE_MAPPING>>) {
const client = new (Object.getPrototypeOf(this).constructor)({
...this._options, ...this._options,
...overrides ...overrides
}) as RedisClientType<M, F, S, RESP>; }) as RedisClientType<_M, _F, _S, _RESP, _TYPE_MAPPING>;
const { commandOptions } = this as ProxyClient;
if (commandOptions) {
return client.withCommandOptions(commandOptions);
}
return client;
} }
connect() { connect() {

View File

@@ -91,6 +91,11 @@ export class DoublyLinkedList<T> {
node.next = undefined; node.next = undefined;
} }
reset() {
this._length = 0;
this._head = this._tail = undefined;
}
*[Symbol.iterator]() { *[Symbol.iterator]() {
let node = this._head; let node = this._head;
while (node !== undefined) { while (node !== undefined) {
@@ -152,6 +157,11 @@ export class SinglyLinkedList<T> {
return node.value; return node.value;
} }
reset() {
this._length = 0;
this._head = this._tail = undefined;
}
*[Symbol.iterator]() { *[Symbol.iterator]() {
let node = this._head; let node = this._head;
while (node !== undefined) { while (node !== undefined) {

View File

@@ -46,6 +46,7 @@ export interface ShardNode<
S extends RedisScripts, S extends RedisScripts,
RESP extends RespVersions RESP extends RespVersions
> extends Node<M, F, S, RESP> { > extends Node<M, F, S, RESP> {
id: string;
host: string; host: string;
port: number; port: number;
readonly: boolean; readonly: boolean;
@@ -173,7 +174,6 @@ export default class RedisClusterSlots<
promises: Array<Promise<unknown>> = [], promises: Array<Promise<unknown>> = [],
eagerConnect = this._options.minimizeConnections !== true; eagerConnect = this._options.minimizeConnections !== true;
type a = typeof shards;
for (const { from, to, master, replicas } of shards) { for (const { from, to, master, replicas } of shards) {
const shard: Shard<M, F, S, RESP> = { const shard: Shard<M, F, S, RESP> = {
master: this._initiateSlotNode(master, false, eagerConnect, addressesInUse, promises) master: this._initiateSlotNode(master, false, eagerConnect, addressesInUse, promises)
@@ -294,19 +294,19 @@ export default class RedisClusterSlots<
} }
private _initiateSlotNode( private _initiateSlotNode(
slotAddress: NodeAddress, shard: NodeAddress & { id: string; },
readonly: boolean, readonly: boolean,
eagerConnent: boolean, eagerConnent: boolean,
addressesInUse: Set<string>, addressesInUse: Set<string>,
promises: Array<Promise<unknown>> promises: Array<Promise<unknown>>
) { ) {
const address = `${slotAddress.host}:${slotAddress.port}`; const address = `${shard.host}:${shard.port}`;
addressesInUse.add(address); addressesInUse.add(address);
let node = this.nodeByAddress.get(address); let node = this.nodeByAddress.get(address);
if (!node) { if (!node) {
node = { node = {
...slotAddress, ...shard,
address, address,
readonly, readonly,
client: undefined client: undefined

View File

@@ -1,4 +1,5 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import CLIENT_GETNAME from './CLIENT_GETNAME'; import CLIENT_GETNAME from './CLIENT_GETNAME';
describe('CLIENT GETNAME', () => { describe('CLIENT GETNAME', () => {
@@ -8,4 +9,11 @@ describe('CLIENT GETNAME', () => {
['CLIENT', 'GETNAME'] ['CLIENT', 'GETNAME']
); );
}); });
testUtils.testWithClient('client.clientGetName', async client => {
assert.equal(
await client.clientGetName(),
null
);
}, GLOBAL.SERVERS.OPEN);
}); });

View File

@@ -1,12 +1,12 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import { ClientKillFilters, transformArguments } from './CLIENT_KILL'; import CLIENT_KILL, { CLIENT_KILL_FILTERS } from './CLIENT_KILL';
describe('CLIENT KILL', () => { describe('CLIENT KILL', () => {
describe('transformArguments', () => { describe('transformArguments', () => {
it('ADDRESS', () => { it('ADDRESS', () => {
assert.deepEqual( assert.deepEqual(
transformArguments({ CLIENT_KILL.transformArguments({
filter: ClientKillFilters.ADDRESS, filter: CLIENT_KILL_FILTERS.ADDRESS,
address: 'ip:6379' address: 'ip:6379'
}), }),
['CLIENT', 'KILL', 'ADDR', 'ip:6379'] ['CLIENT', 'KILL', 'ADDR', 'ip:6379']
@@ -15,8 +15,8 @@ describe('CLIENT KILL', () => {
it('LOCAL_ADDRESS', () => { it('LOCAL_ADDRESS', () => {
assert.deepEqual( assert.deepEqual(
transformArguments({ CLIENT_KILL.transformArguments({
filter: ClientKillFilters.LOCAL_ADDRESS, filter: CLIENT_KILL_FILTERS.LOCAL_ADDRESS,
localAddress: 'ip:6379' localAddress: 'ip:6379'
}), }),
['CLIENT', 'KILL', 'LADDR', 'ip:6379'] ['CLIENT', 'KILL', 'LADDR', 'ip:6379']
@@ -26,8 +26,8 @@ describe('CLIENT KILL', () => {
describe('ID', () => { describe('ID', () => {
it('string', () => { it('string', () => {
assert.deepEqual( assert.deepEqual(
transformArguments({ CLIENT_KILL.transformArguments({
filter: ClientKillFilters.ID, filter: CLIENT_KILL_FILTERS.ID,
id: '1' id: '1'
}), }),
['CLIENT', 'KILL', 'ID', '1'] ['CLIENT', 'KILL', 'ID', '1']
@@ -36,8 +36,8 @@ describe('CLIENT KILL', () => {
it('number', () => { it('number', () => {
assert.deepEqual( assert.deepEqual(
transformArguments({ CLIENT_KILL.transformArguments({
filter: ClientKillFilters.ID, filter: CLIENT_KILL_FILTERS.ID,
id: 1 id: 1
}), }),
['CLIENT', 'KILL', 'ID', '1'] ['CLIENT', 'KILL', 'ID', '1']
@@ -47,8 +47,8 @@ describe('CLIENT KILL', () => {
it('TYPE', () => { it('TYPE', () => {
assert.deepEqual( assert.deepEqual(
transformArguments({ CLIENT_KILL.transformArguments({
filter: ClientKillFilters.TYPE, filter: CLIENT_KILL_FILTERS.TYPE,
type: 'master' type: 'master'
}), }),
['CLIENT', 'KILL', 'TYPE', 'master'] ['CLIENT', 'KILL', 'TYPE', 'master']
@@ -57,8 +57,8 @@ describe('CLIENT KILL', () => {
it('USER', () => { it('USER', () => {
assert.deepEqual( assert.deepEqual(
transformArguments({ CLIENT_KILL.transformArguments({
filter: ClientKillFilters.USER, filter: CLIENT_KILL_FILTERS.USER,
username: 'username' username: 'username'
}), }),
['CLIENT', 'KILL', 'USER', 'username'] ['CLIENT', 'KILL', 'USER', 'username']
@@ -68,15 +68,15 @@ describe('CLIENT KILL', () => {
describe('SKIP_ME', () => { describe('SKIP_ME', () => {
it('undefined', () => { it('undefined', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(ClientKillFilters.SKIP_ME), CLIENT_KILL.transformArguments(CLIENT_KILL_FILTERS.SKIP_ME),
['CLIENT', 'KILL', 'SKIPME'] ['CLIENT', 'KILL', 'SKIPME']
); );
}); });
it('true', () => { it('true', () => {
assert.deepEqual( assert.deepEqual(
transformArguments({ CLIENT_KILL.transformArguments({
filter: ClientKillFilters.SKIP_ME, filter: CLIENT_KILL_FILTERS.SKIP_ME,
skipMe: true skipMe: true
}), }),
['CLIENT', 'KILL', 'SKIPME', 'yes'] ['CLIENT', 'KILL', 'SKIPME', 'yes']
@@ -85,8 +85,8 @@ describe('CLIENT KILL', () => {
it('false', () => { it('false', () => {
assert.deepEqual( assert.deepEqual(
transformArguments({ CLIENT_KILL.transformArguments({
filter: ClientKillFilters.SKIP_ME, filter: CLIENT_KILL_FILTERS.SKIP_ME,
skipMe: false skipMe: false
}), }),
['CLIENT', 'KILL', 'SKIPME', 'no'] ['CLIENT', 'KILL', 'SKIPME', 'no']
@@ -96,12 +96,12 @@ describe('CLIENT KILL', () => {
it('TYPE & SKIP_ME', () => { it('TYPE & SKIP_ME', () => {
assert.deepEqual( assert.deepEqual(
transformArguments([ CLIENT_KILL.transformArguments([
{ {
filter: ClientKillFilters.TYPE, filter: CLIENT_KILL_FILTERS.TYPE,
type: 'master' type: 'master'
}, },
ClientKillFilters.SKIP_ME CLIENT_KILL_FILTERS.SKIP_ME
]), ]),
['CLIENT', 'KILL', 'TYPE', 'master', 'SKIPME'] ['CLIENT', 'KILL', 'TYPE', 'master', 'SKIPME']
); );

View File

@@ -1,6 +1,6 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './CLIENT_NO-EVICT'; import CLIENT_NO_EVICT from './CLIENT_NO-EVICT';
describe('CLIENT NO-EVICT', () => { describe('CLIENT NO-EVICT', () => {
testUtils.isVersionGreaterThanHook([7]); testUtils.isVersionGreaterThanHook([7]);
@@ -8,14 +8,14 @@ describe('CLIENT NO-EVICT', () => {
describe('transformArguments', () => { describe('transformArguments', () => {
it('true', () => { it('true', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(true), CLIENT_NO_EVICT.transformArguments(true),
['CLIENT', 'NO-EVICT', 'ON'] ['CLIENT', 'NO-EVICT', 'ON']
); );
}); });
it('false', () => { it('false', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(false), CLIENT_NO_EVICT.transformArguments(false),
['CLIENT', 'NO-EVICT', 'OFF'] ['CLIENT', 'NO-EVICT', 'OFF']
); );
}); });

View File

@@ -1,19 +1,19 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './CLIENT_PAUSE'; import CLIENT_PAUSE from './CLIENT_PAUSE';
describe('CLIENT PAUSE', () => { describe('CLIENT PAUSE', () => {
describe('transformArguments', () => { describe('transformArguments', () => {
it('simple', () => { it('simple', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(0), CLIENT_PAUSE.transformArguments(0),
['CLIENT', 'PAUSE', '0'] ['CLIENT', 'PAUSE', '0']
); );
}); });
it('with mode', () => { it('with mode', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(0, 'ALL'), CLIENT_PAUSE.transformArguments(0, 'ALL'),
['CLIENT', 'PAUSE', '0', 'ALL'] ['CLIENT', 'PAUSE', '0', 'ALL']
); );
}); });

View File

@@ -1,11 +1,20 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import { transformArguments } from './CLIENT_SETNAME'; import testUtils, { GLOBAL } from '../test-utils';
import CLIENT_SETNAME from './CLIENT_SETNAME';
describe('CLIENT SETNAME', () => { describe('CLIENT SETNAME', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('name'), CLIENT_SETNAME.transformArguments('name'),
['CLIENT', 'SETNAME', 'name'] ['CLIENT', 'SETNAME', 'name']
); );
}); });
testUtils.testWithClient('client.clientSetName', async client => {
assert.equal(
await client.clientSetName('name'),
'OK'
);
}, GLOBAL.SERVERS.OPEN);
}); });

View File

@@ -1,11 +1,11 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './CLUSTER_MYID'; import CLUSTER_MYID from './CLUSTER_MYID';
describe('CLUSTER MYID', () => { describe('CLUSTER MYID', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(), CLUSTER_MYID.transformArguments(),
['CLUSTER', 'MYID'] ['CLUSTER', 'MYID']
); );
}); });

View File

@@ -1,17 +1,17 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './COMMAND'; // import { transformArguments } from './COMMAND';
import { assertPingCommand } from './COMMAND_INFO.spec'; // import { assertPingCommand } from './COMMAND_INFO.spec';
describe('COMMAND', () => { // describe('COMMAND', () => {
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments(), // transformArguments(),
['COMMAND'] // ['COMMAND']
); // );
}); // });
testUtils.testWithClient('client.command', async client => { // testUtils.testWithClient('client.command', async client => {
assertPingCommand((await client.command()).find(command => command.name === 'ping')); // assertPingCommand((await client.command()).find(command => command.name === 'ping'));
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,19 +1,19 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './COMMAND_COUNT'; // import { transformArguments } from './COMMAND_COUNT';
describe('COMMAND COUNT', () => { // describe('COMMAND COUNT', () => {
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments(), // transformArguments(),
['COMMAND', 'COUNT'] // ['COMMAND', 'COUNT']
); // );
}); // });
testUtils.testWithClient('client.commandCount', async client => { // testUtils.testWithClient('client.commandCount', async client => {
assert.equal( // assert.equal(
typeof await client.commandCount(), // typeof await client.commandCount(),
'number' // 'number'
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,19 +1,19 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './COMMAND_GETKEYS'; // import { transformArguments } from './COMMAND_GETKEYS';
describe('COMMAND GETKEYS', () => { // describe('COMMAND GETKEYS', () => {
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments(['GET', 'key']), // transformArguments(['GET', 'key']),
['COMMAND', 'GETKEYS', 'GET', 'key'] // ['COMMAND', 'GETKEYS', 'GET', 'key']
); // );
}); // });
testUtils.testWithClient('client.commandGetKeys', async client => { // testUtils.testWithClient('client.commandGetKeys', async client => {
assert.deepEqual( // assert.deepEqual(
await client.commandGetKeys(['GET', 'key']), // await client.commandGetKeys(['GET', 'key']),
['key'] // ['key']
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,24 +1,24 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './COMMAND_GETKEYSANDFLAGS'; // import { transformArguments } from './COMMAND_GETKEYSANDFLAGS';
describe('COMMAND GETKEYSANDFLAGS', () => { // describe('COMMAND GETKEYSANDFLAGS', () => {
testUtils.isVersionGreaterThanHook([7]); // testUtils.isVersionGreaterThanHook([7]);
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments(['GET', 'key']), // transformArguments(['GET', 'key']),
['COMMAND', 'GETKEYSANDFLAGS', 'GET', 'key'] // ['COMMAND', 'GETKEYSANDFLAGS', 'GET', 'key']
); // );
}); // });
testUtils.testWithClient('client.commandGetKeysAndFlags', async client => { // testUtils.testWithClient('client.commandGetKeysAndFlags', async client => {
assert.deepEqual( // assert.deepEqual(
await client.commandGetKeysAndFlags(['GET', 'key']), // await client.commandGetKeysAndFlags(['GET', 'key']),
[{ // [{
key: 'key', // key: 'key',
flags: ['RO', 'access'] // flags: ['RO', 'access']
}] // }]
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,49 +1,49 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './COMMAND_INFO'; // import { transformArguments } from './COMMAND_INFO';
import { CommandCategories, CommandFlags, CommandReply } from './generic-transformers'; // import { CommandCategories, CommandFlags, CommandReply } from './generic-transformers';
export function assertPingCommand(commandInfo: CommandReply | null | undefined): void { // export function assertPingCommand(commandInfo: CommandReply | null | undefined): void {
assert.deepEqual( // assert.deepEqual(
commandInfo, // commandInfo,
{ // {
name: 'ping', // name: 'ping',
arity: -1, // arity: -1,
flags: new Set( // flags: new Set(
testUtils.isVersionGreaterThan([7]) ? // testUtils.isVersionGreaterThan([7]) ?
[CommandFlags.FAST] : // [CommandFlags.FAST] :
[CommandFlags.STALE, CommandFlags.FAST] // [CommandFlags.STALE, CommandFlags.FAST]
), // ),
firstKeyIndex: 0, // firstKeyIndex: 0,
lastKeyIndex: 0, // lastKeyIndex: 0,
step: 0, // step: 0,
categories: new Set( // categories: new Set(
testUtils.isVersionGreaterThan([6]) ? // testUtils.isVersionGreaterThan([6]) ?
[CommandCategories.FAST, CommandCategories.CONNECTION] : // [CommandCategories.FAST, CommandCategories.CONNECTION] :
[] // []
) // )
} // }
); // );
} // }
describe('COMMAND INFO', () => { // describe('COMMAND INFO', () => {
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments(['PING']), // transformArguments(['PING']),
['COMMAND', 'INFO', 'PING'] // ['COMMAND', 'INFO', 'PING']
); // );
}); // });
describe('client.commandInfo', () => { // describe('client.commandInfo', () => {
testUtils.testWithClient('PING', async client => { // testUtils.testWithClient('PING', async client => {
assertPingCommand((await client.commandInfo(['PING']))[0]); // assertPingCommand((await client.commandInfo(['PING']))[0]);
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('DOSE_NOT_EXISTS', async client => { // testUtils.testWithClient('DOSE_NOT_EXISTS', async client => {
assert.deepEqual( // assert.deepEqual(
await client.commandInfo(['DOSE_NOT_EXISTS']), // await client.commandInfo(['DOSE_NOT_EXISTS']),
[null] // [null]
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });
}); // });

View File

@@ -1,56 +1,56 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, FilterBy } from './COMMAND_LIST'; // import { transformArguments, FilterBy } from './COMMAND_LIST';
describe('COMMAND LIST', () => { // describe('COMMAND LIST', () => {
testUtils.isVersionGreaterThanHook([7]); // testUtils.isVersionGreaterThanHook([7]);
describe('transformArguments', () => { // describe('transformArguments', () => {
it('simple', () => { // it('simple', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments(), // transformArguments(),
['COMMAND', 'LIST'] // ['COMMAND', 'LIST']
); // );
}); // });
describe('with FILTERBY', () => { // describe('with FILTERBY', () => {
it('MODULE', () => { // it('MODULE', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments({ // transformArguments({
filterBy: FilterBy.MODULE, // filterBy: FilterBy.MODULE,
value: 'json' // value: 'json'
}), // }),
['COMMAND', 'LIST', 'FILTERBY', 'MODULE', 'json'] // ['COMMAND', 'LIST', 'FILTERBY', 'MODULE', 'json']
); // );
}); // });
it('ACLCAT', () => { // it('ACLCAT', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments({ // transformArguments({
filterBy: FilterBy.ACLCAT, // filterBy: FilterBy.ACLCAT,
value: 'admin' // value: 'admin'
}), // }),
['COMMAND', 'LIST', 'FILTERBY', 'ACLCAT', 'admin'] // ['COMMAND', 'LIST', 'FILTERBY', 'ACLCAT', 'admin']
); // );
}); // });
it('PATTERN', () => { // it('PATTERN', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments({ // transformArguments({
filterBy: FilterBy.PATTERN, // filterBy: FilterBy.PATTERN,
value: 'a*' // value: 'a*'
}), // }),
['COMMAND', 'LIST', 'FILTERBY', 'PATTERN', 'a*'] // ['COMMAND', 'LIST', 'FILTERBY', 'PATTERN', 'a*']
); // );
}); // });
}); // });
}); // });
testUtils.testWithClient('client.commandList', async client => { // testUtils.testWithClient('client.commandList', async client => {
const commandList = await client.commandList(); // const commandList = await client.commandList();
assert.ok(Array.isArray(commandList)); // assert.ok(Array.isArray(commandList));
for (const command of commandList) { // for (const command of commandList) {
assert.ok(typeof command === 'string'); // assert.ok(typeof command === 'string');
} // }
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,10 +1,10 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import { transformArguments } from './CONFIG_GET'; import CONFIG_GET from './CONFIG_GET';
describe('CONFIG GET', () => { describe('CONFIG GET', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('*'), CONFIG_GET.transformArguments('*'),
['CONFIG', 'GET', '*'] ['CONFIG', 'GET', '*']
); );
}); });

View File

@@ -1,10 +1,10 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import { transformArguments } from './CONFIG_RESETSTAT'; import CONFIG_RESETSTAT from './CONFIG_RESETSTAT';
describe('CONFIG RESETSTAT', () => { describe('CONFIG RESETSTAT', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(), CONFIG_RESETSTAT.transformArguments(),
['CONFIG', 'RESETSTAT'] ['CONFIG', 'RESETSTAT']
); );
}); });

View File

@@ -1,10 +1,10 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import { transformArguments } from './CONFIG_REWRITE'; import CONFIG_REWRITE from './CONFIG_REWRITE';
describe('CONFIG REWRITE', () => { describe('CONFIG REWRITE', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(), CONFIG_REWRITE.transformArguments(),
['CONFIG', 'REWRITE'] ['CONFIG', 'REWRITE']
); );
}); });

View File

@@ -1,18 +1,18 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import { transformArguments } from './CONFIG_SET'; import CONFIG_SET from './CONFIG_SET';
describe('CONFIG SET', () => { describe('CONFIG SET', () => {
describe('transformArguments', () => { describe('transformArguments', () => {
it('set one parameter (old version)', () => { it('set one parameter (old version)', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('parameter', 'value'), CONFIG_SET.transformArguments('parameter', 'value'),
['CONFIG', 'SET', 'parameter', 'value'] ['CONFIG', 'SET', 'parameter', 'value']
); );
}); });
it('set muiltiple parameters', () => { it('set muiltiple parameters', () => {
assert.deepEqual( assert.deepEqual(
transformArguments({ CONFIG_SET.transformArguments({
1: 'a', 1: 'a',
2: 'b', 2: 'b',
3: 'c' 3: 'c'

View File

@@ -1,10 +1,10 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import { transformArguments } from './DISCARD'; import DISCARD from './DISCARD';
describe('DISCARD', () => { describe('DISCARD', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(), DISCARD.transformArguments(),
['DISCARD'] ['DISCARD']
); );
}); });

View File

@@ -1,11 +1,11 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import { transformArguments } from './FAILOVER'; import FAILOVER from './FAILOVER';
describe('FAILOVER', () => { describe('FAILOVER', () => {
describe('transformArguments', () => { describe('transformArguments', () => {
it('simple', () => { it('simple', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(), FAILOVER.transformArguments(),
['FAILOVER'] ['FAILOVER']
); );
}); });
@@ -13,7 +13,7 @@ describe('FAILOVER', () => {
describe('with TO', () => { describe('with TO', () => {
it('simple', () => { it('simple', () => {
assert.deepEqual( assert.deepEqual(
transformArguments({ FAILOVER.transformArguments({
TO: { TO: {
host: 'host', host: 'host',
port: 6379 port: 6379
@@ -25,7 +25,7 @@ describe('FAILOVER', () => {
it('with FORCE', () => { it('with FORCE', () => {
assert.deepEqual( assert.deepEqual(
transformArguments({ FAILOVER.transformArguments({
TO: { TO: {
host: 'host', host: 'host',
port: 6379, port: 6379,
@@ -39,7 +39,7 @@ describe('FAILOVER', () => {
it('with ABORT', () => { it('with ABORT', () => {
assert.deepEqual( assert.deepEqual(
transformArguments({ FAILOVER.transformArguments({
ABORT: true ABORT: true
}), }),
['FAILOVER', 'ABORT'] ['FAILOVER', 'ABORT']
@@ -48,7 +48,7 @@ describe('FAILOVER', () => {
it('with TIMEOUT', () => { it('with TIMEOUT', () => {
assert.deepEqual( assert.deepEqual(
transformArguments({ FAILOVER.transformArguments({
TIMEOUT: 1 TIMEOUT: 1
}), }),
['FAILOVER', 'TIMEOUT', '1'] ['FAILOVER', 'TIMEOUT', '1']
@@ -57,7 +57,7 @@ describe('FAILOVER', () => {
it('with TO, ABORT, TIMEOUT', () => { it('with TO, ABORT, TIMEOUT', () => {
assert.deepEqual( assert.deepEqual(
transformArguments({ FAILOVER.transformArguments({
TO: { TO: {
host: 'host', host: 'host',
port: 6379 port: 6379

View File

@@ -1,14 +1,14 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { MATH_FUNCTION, loadMathFunction } from '../client/index.spec'; import { MATH_FUNCTION, loadMathFunction } from './FUNCTION_LOAD.spec';
import { transformArguments } from './FCALL'; import FCALL from './FCALL';
describe('FCALL', () => { describe('FCALL', () => {
testUtils.isVersionGreaterThanHook([7]); testUtils.isVersionGreaterThanHook([7]);
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('function', { FCALL.transformArguments('function', {
keys: ['key'], keys: ['key'],
arguments: ['argument'] arguments: ['argument']
}), }),

View File

@@ -1,19 +1,9 @@
import { evalFirstKeyIndex, EvalOptions, pushEvalArguments } from './generic-transformers'; import { Command } from '../RESP/types';
import EVAL, { EvalOptions, transformEvalArguments } from './EVAL';
export const FIRST_KEY_INDEX = evalFirstKeyIndex;
export function transformArguments(fn: string, options?: EvalOptions): Array<string> {
return pushEvalArguments(['FCALL', fn], options);
}
import { SimpleStringReply, Command } from '../RESP/types';
export default { export default {
FIRST_KEY_INDEX: undefined, FIRST_KEY_INDEX: EVAL.FIRST_KEY_INDEX,
IS_READ_ONLY: false, IS_READ_ONLY: false,
transformArguments() { transformArguments: transformEvalArguments.bind(undefined, 'FCALL'),
return ['FCALL']; transformReply: EVAL.transformReply
},
transformReply: undefined as unknown as () => SimpleStringReply
} as const satisfies Command; } as const satisfies Command;

View File

@@ -1,14 +1,14 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { MATH_FUNCTION, loadMathFunction } from '../client/index.spec'; import { MATH_FUNCTION, loadMathFunction } from './FUNCTION_LOAD.spec';
import { transformArguments } from './FCALL_RO'; import FCALL_RO from './FCALL_RO';
describe('FCALL_RO', () => { describe('FCALL_RO', () => {
testUtils.isVersionGreaterThanHook([7]); testUtils.isVersionGreaterThanHook([7]);
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('function', { FCALL_RO.transformArguments('function', {
keys: ['key'], keys: ['key'],
arguments: ['argument'] arguments: ['argument']
}), }),

View File

@@ -1,9 +1,9 @@
import { evalFirstKeyIndex, EvalOptions, pushEvalArguments } from './generic-transformers'; import { Command } from '../RESP/types';
import EVAL, { EvalOptions, transformEvalArguments } from './EVAL';
export const FIRST_KEY_INDEX = evalFirstKeyIndex; export default {
FIRST_KEY_INDEX: EVAL.FIRST_KEY_INDEX,
export const IS_READ_ONLY = true; IS_READ_ONLY: false,
transformArguments: transformEvalArguments.bind(undefined, 'FCALL_RO'),
export function transformArguments(fn: string, options?: EvalOptions): Array<string> { transformReply: EVAL.transformReply
return pushEvalArguments(['FCALL_RO', fn], options); } as const satisfies Command;
}

View File

@@ -1,14 +1,14 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import { MATH_FUNCTION, loadMathFunction } from '../client/index.spec';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './FUNCTION_DELETE'; import FUNCTION_DELETE from './FUNCTION_DELETE';
import { MATH_FUNCTION, loadMathFunction } from './FUNCTION_LOAD.spec';
describe('FUNCTION DELETE', () => { describe('FUNCTION DELETE', () => {
testUtils.isVersionGreaterThanHook([7]); testUtils.isVersionGreaterThanHook([7]);
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('library'), FUNCTION_DELETE.transformArguments('library'),
['FUNCTION', 'DELETE', 'library'] ['FUNCTION', 'DELETE', 'library']
); );
}); });

View File

@@ -2,7 +2,7 @@ import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
export default { export default {
FIRST_KEY_INDEX: undefined, FIRST_KEY_INDEX: undefined,
IS_READ_ONLY: true, IS_READ_ONLY: false,
transformArguments(library: RedisArgument) { transformArguments(library: RedisArgument) {
return ['FUNCTION', 'DELETE', library]; return ['FUNCTION', 'DELETE', library];
}, },

View File

@@ -1,13 +1,13 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './FUNCTION_DUMP'; import FUNCTION_DUMP from './FUNCTION_DUMP';
describe('FUNCTION DUMP', () => { describe('FUNCTION DUMP', () => {
testUtils.isVersionGreaterThanHook([7]); testUtils.isVersionGreaterThanHook([7]);
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(), FUNCTION_DUMP.transformArguments(),
['FUNCTION', 'DUMP'] ['FUNCTION', 'DUMP']
); );
}); });

View File

@@ -1,6 +1,6 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './FUNCTION_FLUSH'; import FUNCTION_FLUSH from './FUNCTION_FLUSH';
describe('FUNCTION FLUSH', () => { describe('FUNCTION FLUSH', () => {
testUtils.isVersionGreaterThanHook([7]); testUtils.isVersionGreaterThanHook([7]);
@@ -8,14 +8,14 @@ describe('FUNCTION FLUSH', () => {
describe('transformArguments', () => { describe('transformArguments', () => {
it('simple', () => { it('simple', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(), FUNCTION_FLUSH.transformArguments(),
['FUNCTION', 'FLUSH'] ['FUNCTION', 'FLUSH']
); );
}); });
it('with mode', () => { it('with mode', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('SYNC'), FUNCTION_FLUSH.transformArguments('SYNC'),
['FUNCTION', 'FLUSH', 'SYNC'] ['FUNCTION', 'FLUSH', 'SYNC']
); );
}); });

View File

@@ -3,7 +3,7 @@ import { RedisFlushModes } from './FLUSHALL';
export default { export default {
FIRST_KEY_INDEX: undefined, FIRST_KEY_INDEX: undefined,
IS_READ_ONLY: true, IS_READ_ONLY: false,
transformArguments(mode?: RedisFlushModes) { transformArguments(mode?: RedisFlushModes) {
const args = ['FUNCTION', 'FLUSH']; const args = ['FUNCTION', 'FLUSH'];
@@ -13,5 +13,5 @@ export default {
return args; return args;
}, },
transformReply: undefined as unknown as () => SimpleStringReply transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
} as const satisfies Command; } as const satisfies Command;

View File

@@ -1,13 +1,13 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils from '../test-utils'; import testUtils from '../test-utils';
import { transformArguments } from './FUNCTION_KILL'; import FUNCTION_KILL from './FUNCTION_KILL';
describe('FUNCTION KILL', () => { describe('FUNCTION KILL', () => {
testUtils.isVersionGreaterThanHook([7]); testUtils.isVersionGreaterThanHook([7]);
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(), FUNCTION_KILL.transformArguments(),
['FUNCTION', 'KILL'] ['FUNCTION', 'KILL']
); );
}); });

View File

@@ -1,7 +1,7 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { MATH_FUNCTION, loadMathFunction } from '../client/index.spec'; import FUNCTION_LIST from './FUNCTION_LIST';
import { transformArguments } from './FUNCTION_LIST'; import { MATH_FUNCTION, loadMathFunction } from './FUNCTION_LOAD.spec';
describe('FUNCTION LIST', () => { describe('FUNCTION LIST', () => {
testUtils.isVersionGreaterThanHook([7]); testUtils.isVersionGreaterThanHook([7]);
@@ -9,15 +9,17 @@ describe('FUNCTION LIST', () => {
describe('transformArguments', () => { describe('transformArguments', () => {
it('simple', () => { it('simple', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(), FUNCTION_LIST.transformArguments(),
['FUNCTION', 'LIST'] ['FUNCTION', 'LIST']
); );
}); });
it('with pattern', () => { it('with LIBRARYNAME', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('patter*'), FUNCTION_LIST.transformArguments({
['FUNCTION', 'LIST', 'patter*'] LIBRARYNAME: 'patter*'
}),
['FUNCTION', 'LIST', 'LIBRARYNAME', 'patter*']
); );
}); });
}); });
@@ -28,7 +30,7 @@ describe('FUNCTION LIST', () => {
assert.deepEqual( assert.deepEqual(
await client.functionList(), await client.functionList(),
[{ [{
libraryName: MATH_FUNCTION.name, library_name: MATH_FUNCTION.name,
engine: MATH_FUNCTION.engine, engine: MATH_FUNCTION.engine,
functions: [{ functions: [{
name: MATH_FUNCTION.library.square.NAME, name: MATH_FUNCTION.library.square.NAME,

View File

@@ -1,16 +1,45 @@
// import { RedisCommandArguments } from '.'; import { RedisArgument, TuplesToMapReply, BlobStringReply, ArrayReply, NullReply, SetReply, Resp2Reply, CommandArguments, Command } from '../RESP/types';
// import { FunctionListItemReply, FunctionListRawItemReply, transformFunctionListItemReply } from './generic-transformers';
// export function transformArguments(pattern?: string): RedisCommandArguments { export interface FunctionListOptions {
// const args = ['FUNCTION', 'LIST']; LIBRARYNAME?: RedisArgument;
}
// if (pattern) { export type FunctionListReplyItem = [
// args.push(pattern); [BlobStringReply<'library_name'>, BlobStringReply],
// } [BlobStringReply<'engine'>, BlobStringReply],
[BlobStringReply<'functions'>, ArrayReply<TuplesToMapReply<[
[BlobStringReply<'name'>, BlobStringReply],
[BlobStringReply<'description'>, BlobStringReply | NullReply],
[BlobStringReply<'flags'>, SetReply<BlobStringReply>],
]>>]
]
// return args; export type FunctionListReply = ArrayReply<TuplesToMapReply<FunctionListReplyItem>>;
// }
// export function transformReply(reply: Array<FunctionListRawItemReply>): Array<FunctionListItemReply> { export default {
// return reply.map(transformFunctionListItemReply); FIRST_KEY_INDEX: undefined,
// } IS_READ_ONLY: false,
transformArguments(options?: FunctionListOptions) {
const args: CommandArguments = ['FUNCTION', 'LIST'];
if (options?.LIBRARYNAME) {
args.push('LIBRARYNAME', options.LIBRARYNAME);
}
return args;
},
transformReply: {
2: (reply: Resp2Reply<FunctionListReply>) => {
return reply.map(library => ({
library_name: library[1],
engine: library[3],
functions: library[5].map(fn => ({
name: fn[1],
description: fn[3],
flags: fn[5]
}))
}));
},
3: undefined as unknown as () => FunctionListReply
}
} as const satisfies Command;

View File

@@ -1,7 +1,7 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { MATH_FUNCTION, loadMathFunction } from '../client/index.spec'; import FUNCTION_LIST_WITHCODE from './FUNCTION_LIST_WITHCODE';
import { transformArguments } from './FUNCTION_LIST_WITHCODE'; import { MATH_FUNCTION, loadMathFunction } from './FUNCTION_LOAD.spec';
describe('FUNCTION LIST WITHCODE', () => { describe('FUNCTION LIST WITHCODE', () => {
testUtils.isVersionGreaterThanHook([7]); testUtils.isVersionGreaterThanHook([7]);
@@ -9,15 +9,17 @@ describe('FUNCTION LIST WITHCODE', () => {
describe('transformArguments', () => { describe('transformArguments', () => {
it('simple', () => { it('simple', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(), FUNCTION_LIST_WITHCODE.transformArguments(),
['FUNCTION', 'LIST', 'WITHCODE'] ['FUNCTION', 'LIST', 'WITHCODE']
); );
}); });
it('with pattern', () => { it('with LIBRARYNAME', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('patter*'), FUNCTION_LIST_WITHCODE.transformArguments({
['FUNCTION', 'LIST', 'patter*', 'WITHCODE'] LIBRARYNAME: 'patter*'
}),
['FUNCTION', 'LIST', 'LIBRARYNAME', 'patter*', 'WITHCODE']
); );
}); });
}); });
@@ -28,14 +30,14 @@ describe('FUNCTION LIST WITHCODE', () => {
assert.deepEqual( assert.deepEqual(
await client.functionListWithCode(), await client.functionListWithCode(),
[{ [{
libraryName: MATH_FUNCTION.name, library_name: MATH_FUNCTION.name,
engine: MATH_FUNCTION.engine, engine: MATH_FUNCTION.engine,
functions: [{ functions: [{
name: MATH_FUNCTION.library.square.NAME, name: MATH_FUNCTION.library.square.NAME,
description: null, description: null,
flags: ['no-writes'] flags: ['no-writes']
}], }],
libraryCode: MATH_FUNCTION.code library_code: MATH_FUNCTION.code
}] }]
); );
}, GLOBAL.SERVERS.OPEN); }, GLOBAL.SERVERS.OPEN);

View File

@@ -1,26 +1,32 @@
// import { RedisCommandArguments } from '.'; import { TuplesToMapReply, BlobStringReply, ArrayReply, Command, Resp2Reply } from '../RESP/types';
// import { transformArguments as transformFunctionListArguments } from './FUNCTION_LIST'; import FUNCTION_LIST, { FunctionListReplyItem } from './FUNCTION_LIST';
// import { FunctionListItemReply, FunctionListRawItemReply, transformFunctionListItemReply } from './generic-transformers';
// export function transformArguments(pattern?: string): RedisCommandArguments { export type FunctionListWithCodeReply = ArrayReply<TuplesToMapReply<[
// const args = transformFunctionListArguments(pattern); ...FunctionListReplyItem,
// args.push('WITHCODE'); [BlobStringReply<'library_code'>, BlobStringReply],
// return args; ]>>;
// }
// type FunctionListWithCodeRawItemReply = [ export default {
// ...FunctionListRawItemReply, FIRST_KEY_INDEX: FUNCTION_LIST.FIRST_KEY_INDEX,
// 'library_code', IS_READ_ONLY: FUNCTION_LIST.IS_READ_ONLY,
// string transformArguments(...args: Parameters<typeof FUNCTION_LIST.transformArguments>) {
// ]; const redisArgs = FUNCTION_LIST.transformArguments(...args);
redisArgs.push('WITHCODE');
// interface FunctionListWithCodeItemReply extends FunctionListItemReply { return redisArgs;
// libraryCode: string; },
// } transformReply: {
2: (reply: Resp2Reply<FunctionListWithCodeReply>) => {
// export function transformReply(reply: Array<FunctionListWithCodeRawItemReply>): Array<FunctionListWithCodeItemReply> { return reply.map((library: any) => ({
// return reply.map(library => ({ library_name: library[1],
// ...transformFunctionListItemReply(library as unknown as FunctionListRawItemReply), engine: library[3],
// libraryCode: library[7] functions: library[5].map((fn: any) => ({
// })); name: fn[1],
// } description: fn[3],
flags: fn[5]
})),
library_code: library[7]
})) as unknown as number;
},
3: undefined as unknown as () => FunctionListWithCodeReply
}
} as const satisfies Command;

View File

@@ -1,7 +1,45 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { MATH_FUNCTION } from '../client/index.spec'; import FUNCTION_LOAD from './FUNCTION_LOAD';
import { transformArguments } from './FUNCTION_LOAD'; import { RedisClientType } from '../client';
import { NumberReply, RedisFunctions, RedisModules, RedisScripts, RespVersions } from '../RESP/types';
export const MATH_FUNCTION = {
name: 'math',
engine: 'LUA',
code:
`#!LUA name=math
redis.register_function{
function_name = "square",
callback = function(keys, args) return args[1] * args[1] end,
flags = { "no-writes" }
}`,
library: {
square: {
NAME: 'square',
IS_READ_ONLY: true,
NUMBER_OF_KEYS: 0,
transformArguments(number: number) {
return [number.toString()];
},
transformReply: undefined as unknown as () => NumberReply
}
}
};
export function loadMathFunction<
M extends RedisModules,
F extends RedisFunctions,
S extends RedisScripts,
RESP extends RespVersions
>(
client: RedisClientType<M, F, S, RESP>
) {
return client.functionLoad(
MATH_FUNCTION.code,
{ REPLACE: true }
);
}
describe('FUNCTION LOAD', () => { describe('FUNCTION LOAD', () => {
testUtils.isVersionGreaterThanHook([7]); testUtils.isVersionGreaterThanHook([7]);
@@ -9,14 +47,14 @@ describe('FUNCTION LOAD', () => {
describe('transformArguments', () => { describe('transformArguments', () => {
it('simple', () => { it('simple', () => {
assert.deepEqual( assert.deepEqual(
transformArguments( 'code'), FUNCTION_LOAD.transformArguments('code'),
['FUNCTION', 'LOAD', 'code'] ['FUNCTION', 'LOAD', 'code']
); );
}); });
it('with REPLACE', () => { it('with REPLACE', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('code', { FUNCTION_LOAD.transformArguments('code', {
REPLACE: true REPLACE: true
}), }),
['FUNCTION', 'LOAD', 'REPLACE', 'code'] ['FUNCTION', 'LOAD', 'REPLACE', 'code']
@@ -26,10 +64,7 @@ describe('FUNCTION LOAD', () => {
testUtils.testWithClient('client.functionLoad', async client => { testUtils.testWithClient('client.functionLoad', async client => {
assert.equal( assert.equal(
await client.functionLoad( await loadMathFunction(client),
MATH_FUNCTION.code,
{ REPLACE: true }
),
MATH_FUNCTION.name MATH_FUNCTION.name
); );
}, GLOBAL.SERVERS.OPEN); }, GLOBAL.SERVERS.OPEN);

View File

@@ -1,22 +1,22 @@
// import { RedisCommandArguments } from '.'; import { RedisArgument, CommandArguments, BlobStringReply, Command } from '../RESP/types';
// interface FunctionLoadOptions { export interface FunctionLoadOptions {
// REPLACE?: boolean; REPLACE?: boolean;
// } }
// export function transformArguments( export default {
// code: string, FIRST_KEY_INDEX: undefined,
// options?: FunctionLoadOptions IS_READ_ONLY: false,
// ): RedisCommandArguments { transformArguments(code: RedisArgument, options?: FunctionLoadOptions) {
// const args = ['FUNCTION', 'LOAD']; const args: CommandArguments = ['FUNCTION', 'LOAD'];
// if (options?.REPLACE) { if (options?.REPLACE) {
// args.push('REPLACE'); args.push('REPLACE');
// } }
// args.push(code); args.push(code);
// return args; return args;
// } },
transformReply: undefined as unknown as () => BlobStringReply
// export declare function transformReply(): string; } as const satisfies Command;

View File

@@ -1,6 +1,7 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './FUNCTION_RESTORE'; import FUNCTION_RESTORE from './FUNCTION_RESTORE';
import { RESP_TYPES } from '../RESP/decoder';
describe('FUNCTION RESTORE', () => { describe('FUNCTION RESTORE', () => {
testUtils.isVersionGreaterThanHook([7]); testUtils.isVersionGreaterThanHook([7]);
@@ -8,14 +9,16 @@ describe('FUNCTION RESTORE', () => {
describe('transformArguments', () => { describe('transformArguments', () => {
it('simple', () => { it('simple', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('dump'), FUNCTION_RESTORE.transformArguments('dump'),
['FUNCTION', 'RESTORE', 'dump'] ['FUNCTION', 'RESTORE', 'dump']
); );
}); });
it('with mode', () => { it('with mode', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('dump', 'APPEND'), FUNCTION_RESTORE.transformArguments('dump', {
mode: 'APPEND'
}),
['FUNCTION', 'RESTORE', 'dump', 'APPEND'] ['FUNCTION', 'RESTORE', 'dump', 'APPEND']
); );
}); });
@@ -24,11 +27,9 @@ describe('FUNCTION RESTORE', () => {
testUtils.testWithClient('client.functionRestore', async client => { testUtils.testWithClient('client.functionRestore', async client => {
assert.equal( assert.equal(
await client.functionRestore( await client.functionRestore(
await client.functionDump( await client.withTypeMapping({
client.commandOptions({ [RESP_TYPES.BLOB_STRING]: Buffer
returnBuffers: true }).functionDump(),
})
),
'FLUSH' 'FLUSH'
), ),
'OK' 'OK'

View File

@@ -1,16 +1,20 @@
// import { RedisCommandArgument, RedisCommandArguments } from '.'; import { SimpleStringReply, Command, RedisArgument } from '../RESP/types';
// export function transformArguments( export interface FunctionRestoreOptions {
// dump: RedisCommandArgument, mode?: 'FLUSH' | 'APPEND' | 'REPLACE';
// mode?: 'FLUSH' | 'APPEND' | 'REPLACE' }
// ): RedisCommandArguments {
// const args = ['FUNCTION', 'RESTORE', dump];
// if (mode) { export default {
// args.push(mode); FIRST_KEY_INDEX: undefined,
// } IS_READ_ONLY: false,
transformArguments(dump: RedisArgument, options?: FunctionRestoreOptions) {
const args = ['FUNCTION', 'RESTORE', dump];
// return args; if (options?.mode) {
// } args.push(options.mode);
}
// export declare function transformReply(): 'OK'; return args;
},
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
} as const satisfies Command;

View File

@@ -1,25 +1,25 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './FUNCTION_STATS'; // import { transformArguments } from './FUNCTION_STATS';
describe('FUNCTION STATS', () => { // describe('FUNCTION STATS', () => {
testUtils.isVersionGreaterThanHook([7]); // testUtils.isVersionGreaterThanHook([7]);
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments(), // transformArguments(),
['FUNCTION', 'STATS'] // ['FUNCTION', 'STATS']
); // );
}); // });
testUtils.testWithClient('client.functionStats', async client => { // testUtils.testWithClient('client.functionStats', async client => {
const stats = await client.functionStats(); // const stats = await client.functionStats();
assert.equal(stats.runningScript, null); // assert.equal(stats.runningScript, null);
assert.equal(typeof stats.engines, 'object'); // assert.equal(typeof stats.engines, 'object');
for (const [engine, { librariesCount, functionsCount }] of Object.entries(stats.engines)) { // for (const [engine, { librariesCount, functionsCount }] of Object.entries(stats.engines)) {
assert.equal(typeof engine, 'string'); // assert.equal(typeof engine, 'string');
assert.equal(typeof librariesCount, 'number'); // assert.equal(typeof librariesCount, 'number');
assert.equal(typeof functionsCount, 'number'); // assert.equal(typeof functionsCount, 'number');
} // }
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,5 @@
import { ArrayReply, BlobStringReply, CommandArguments, DoubleReply, NullReply, RedisArgument, Resp2Reply } from '../RESP/types'; import { ArrayReply, BlobStringReply, CommandArguments, DoubleReply, NullReply, RedisArgument, Resp2Reply } from '../RESP/types';
// export function transformBooleanReply(reply: number): boolean {
// return reply === 1;
// }
// export function transformBooleanArrayReply(reply: Array<number>): Array<boolean> {
// return reply.map(transformBooleanReply);
// }
export type BitValue = 0 | 1; export type BitValue = 0 | 1;
export function transformDoubleReply(reply: BlobStringReply): number { export function transformDoubleReply(reply: BlobStringReply): number {

View File

@@ -41,6 +41,7 @@ import CLUSTER_MEET from './CLUSTER_MEET';
import CLUSTER_MYID from './CLUSTER_MYID'; import CLUSTER_MYID from './CLUSTER_MYID';
import CLUSTER_REPLICATE from './CLUSTER_REPLICATE'; import CLUSTER_REPLICATE from './CLUSTER_REPLICATE';
import COPY from './COPY'; import COPY from './COPY';
import DBSIZE from './DBSIZE';
import DECR from './DECR'; import DECR from './DECR';
import DECRBY from './DECRBY'; import DECRBY from './DECRBY';
import DEL from './DEL'; import DEL from './DEL';
@@ -79,6 +80,17 @@ import EXPIREAT from './EXPIREAT';
import EXPIRETIME from './EXPIRETIME'; import EXPIRETIME from './EXPIRETIME';
import FLUSHALL from './FLUSHALL'; import FLUSHALL from './FLUSHALL';
import FLUSHDB from './FLUSHDB'; import FLUSHDB from './FLUSHDB';
import FCALL from './FCALL';
import FCALL_RO from './FCALL_RO';
import FUNCTION_DELETE from './FUNCTION_DELETE';
import FUNCTION_DUMP from './FUNCTION_DUMP';
import FUNCTION_FLUSH from './FUNCTION_FLUSH';
import FUNCTION_KILL from './FUNCTION_KILL';
import FUNCTION_LIST_WITHCODE from './FUNCTION_LIST_WITHCODE';
import FUNCTION_LIST from './FUNCTION_LIST';
import FUNCTION_LOAD from './FUNCTION_LOAD';
// import FUNCTION_RESTORE from './FUNCTION_RESTORE';
// import FUNCTION_STATS from './FUNCTION_STATS';
import HDEL from './HDEL'; import HDEL from './HDEL';
import HELLO from './HELLO'; import HELLO from './HELLO';
import HEXISTS from './HEXISTS'; import HEXISTS from './HEXISTS';
@@ -246,6 +258,786 @@ import ZUNION from './ZUNION';
import ZUNIONSTORE from './ZUNIONSTORE'; import ZUNIONSTORE from './ZUNIONSTORE';
import { Command } from '../RESP/types'; import { Command } from '../RESP/types';
type ACL_CAT = typeof import('./ACL_CAT').default;
type ACL_DRYRUN = typeof import('./ACL_DRYRUN').default;
type ACL_GENPASS = typeof import('./ACL_GENPASS').default;
type ACL_GETUSER = typeof import('./ACL_GETUSER').default;
type ACL_LIST = typeof import('./ACL_LIST').default;
type ACL_LOAD = typeof import('./ACL_LOAD').default;
type ACL_LOG_RESET = typeof import('./ACL_LOG_RESET').default;
type ACL_LOG = typeof import('./ACL_LOG').default;
type ACL_SAVE = typeof import('./ACL_SAVE').default;
type ACL_SETUSER = typeof import('./ACL_SETUSER').default;
type ACL_USERS = typeof import('./ACL_USERS').default;
type ACL_WHOAMI = typeof import('./ACL_WHOAMI').default;
type APPEND = typeof import('./APPEND').default;
type ASKING = typeof import('./ASKING').default;
type AUTH = typeof import('./AUTH').default;
type BGREWRITEAOF = typeof import('./BGREWRITEAOF').default;
type BGSAVE = typeof import('./BGSAVE').default;
type BITCOUNT = typeof import('./BITCOUNT').default;
type BITFIELD_RO = typeof import('./BITFIELD_RO').default;
type BITFIELD = typeof import('./BITFIELD').default;
type BITOP = typeof import('./BITOP').default;
type BITPOS = typeof import('./BITPOS').default;
type BLMOVE = typeof import('./BLMOVE').default;
type BLMPOP = typeof import('./BLMPOP').default;
type BLPOP = typeof import('./BLPOP').default;
type BRPOP = typeof import('./BRPOP').default;
type BRPOPLPUSH = typeof import('./BRPOPLPUSH').default;
type CLIENT_CACHING = typeof import('./CLIENT_CACHING').default;
type CLIENT_GETNAME = typeof import('./CLIENT_GETNAME').default;
type CLIENT_GETREDIR = typeof import('./CLIENT_GETREDIR').default;
type CLIENT_ID = typeof import('./CLIENT_ID').default;
type CLIENT_INFO = typeof import('./CLIENT_INFO').default;
type CLIENT_KILL = typeof import('./CLIENT_KILL').default;
type CLIENT_LIST = typeof import('./CLIENT_LIST').default;
type CLIENT_NO_EVICT = typeof import('./CLIENT_NO-EVICT').default;
type CLIENT_PAUSE = typeof import('./CLIENT_PAUSE').default;
type CLIENT_SETNAME = typeof import('./CLIENT_SETNAME').default;
type CLUSTER_ADDSLOTS = typeof import('./CLUSTER_ADDSLOTS').default;
type CLUSTER_SLOTS = typeof import('./CLUSTER_SLOTS').default;
type CLUSTER_MEET = typeof import('./CLUSTER_MEET').default;
type CLUSTER_MYID = typeof import('./CLUSTER_MYID').default;
type CLUSTER_REPLICATE = typeof import('./CLUSTER_REPLICATE').default;
type COPY = typeof import('./COPY').default;
type DBSIZE = typeof DBSIZE;
type DECR = typeof import('./DECR').default;
type DECRBY = typeof import('./DECRBY').default;
type DEL = typeof import('./DEL').default;
type DUMP = typeof import('./DUMP').default;
type ECHO = typeof import('./ECHO').default;
type EVAL_RO = typeof import('./EVAL_RO').default;
type EVAL = typeof import('./EVAL').default;
type EVALSHA_RO = typeof import('./EVALSHA_RO').default;
type EVALSHA = typeof import('./EVALSHA').default;
type GEOADD = typeof import('./GEOADD').default;
type GEODIST = typeof import('./GEODIST').default;
type GEOHASH = typeof import('./GEOHASH').default;
type GEOPOS = typeof import('./GEOPOS').default;
type GEORADIUS_RO_WITH = typeof import('./GEORADIUS_RO_WITH').default;
type GEORADIUS_RO = typeof import('./GEORADIUS_RO').default;
type GEORADIUS_STORE = typeof import('./GEORADIUS_STORE').default;
type GEORADIUS_WITH = typeof import('./GEORADIUS_WITH').default;
type GEORADIUS = typeof import('./GEORADIUS').default;
type GEORADIUSBYMEMBER_RO_WITH = typeof import('./GEORADIUSBYMEMBER_RO_WITH').default;
type GEORADIUSBYMEMBER_RO = typeof import('./GEORADIUSBYMEMBER_RO').default;
type GEORADIUSBYMEMBER_STORE = typeof import('./GEORADIUSBYMEMBER_STORE').default;
type GEORADIUSBYMEMBER_WITH = typeof import('./GEORADIUSBYMEMBER_WITH').default;
type GEORADIUSBYMEMBER = typeof import('./GEORADIUSBYMEMBER').default;
type GEOSEARCH_WITH = typeof import('./GEOSEARCH_WITH').default;
type GEOSEARCH = typeof import('./GEOSEARCH').default;
type GEOSEARCHSTORE = typeof import('./GEOSEARCHSTORE').default;
type GET = typeof import('./GET').default;
type GETBIT = typeof import('./GETBIT').default;
type GETDEL = typeof import('./GETDEL').default;
type GETEX = typeof import('./GETEX').default;
type GETRANGE = typeof import('./GETRANGE').default;
type GETSET = typeof import('./GETSET').default;
type EXISTS = typeof import('./EXISTS').default;
type EXPIRE = typeof import('./EXPIRE').default;
type EXPIREAT = typeof import('./EXPIREAT').default;
type EXPIRETIME = typeof import('./EXPIRETIME').default;
type FLUSHALL = typeof import('./FLUSHALL').default;
type FLUSHDB = typeof import('./FLUSHDB').default;
type FCALL = typeof import('./FCALL').default;
type FCALL_RO = typeof import('./FCALL_RO').default;
type FUNCTION_DELETE = typeof import('./FUNCTION_DELETE').default;
type FUNCTION_DUMP = typeof import('./FUNCTION_DUMP').default;
type FUNCTION_FLUSH = typeof import('./FUNCTION_FLUSH').default;
type FUNCTION_KILL = typeof import('./FUNCTION_KILL').default;
type FUNCTION_LIST_WITHCODE = typeof import('./FUNCTION_LIST_WITHCODE').default;
type FUNCTION_LIST = typeof import('./FUNCTION_LIST').default;
type FUNCTION_LOAD = typeof import('./FUNCTION_LOAD').default;
// type FUNCTION_RESTORE = typeof import('./FUNCTION_RESTORE').default;
// type FUNCTION_STATS = typeof import('./FUNCTION_STATS').default;
type HDEL = typeof import('./HDEL').default;
type HELLO = typeof import('./HELLO').default;
type HEXISTS = typeof import('./HEXISTS').default;
type HGET = typeof import('./HGET').default;
type HGETALL = typeof import('./HGETALL').default;
type HINCRBY = typeof import('./HINCRBY').default;
type HINCRBYFLOAT = typeof import('./HINCRBYFLOAT').default;
type HKEYS = typeof import('./HKEYS').default;
type HLEN = typeof import('./HLEN').default;
type HMGET = typeof import('./HMGET').default;
type HRANDFIELD_COUNT_WITHVALUES = typeof import('./HRANDFIELD_COUNT_WITHVALUES').default;
type HRANDFIELD_COUNT = typeof import('./HRANDFIELD_COUNT').default;
type HRANDFIELD = typeof import('./HRANDFIELD').default;
type HSCAN = typeof import('./HSCAN').default;
type HSET = typeof import('./HSET').default;
type HSETNX = typeof import('./HSETNX').default;
type HSTRLEN = typeof import('./HSTRLEN').default;
type HVALS = typeof import('./HVALS').default;
type INCR = typeof import('./INCR').default;
type INCRBY = typeof import('./INCRBY').default;
type INCRBYFLOAT = typeof import('./INCRBYFLOAT').default;
type INFO = typeof import('./INFO').default;
type KEYS = typeof import('./KEYS').default;
type LASTSAVE = typeof import('./LASTSAVE').default;
type LCS_IDX_WITHMATCHLEN = typeof import('./LCS_IDX_WITHMATCHLEN').default;
type LCS_IDX = typeof import('./LCS_IDX').default;
type LCS_LEN = typeof import('./LCS_LEN').default;
type LCS = typeof import('./LCS').default;
type LINDEX = typeof import('./LINDEX').default;
type LINSERT = typeof import('./LINSERT').default;
type LLEN = typeof import('./LLEN').default;
type LMOVE = typeof import('./LMOVE').default;
type LMPOP = typeof import('./LMPOP').default;
type LOLWUT = typeof import('./LOLWUT').default;
type LPOP_COUNT = typeof import('./LPOP_COUNT').default;
type LPOP = typeof import('./LPOP').default;
type LPOS_COUNT = typeof import('./LPOS_COUNT').default;
type LPOS = typeof import('./LPOS').default;
type LPUSH = typeof import('./LPUSH').default;
type LPUSHX = typeof import('./LPUSHX').default;
type LRANGE = typeof import('./LRANGE').default;
type LREM = typeof import('./LREM').default;
type LSET = typeof import('./LSET').default;
type LTRIM = typeof import('./LTRIM').default;
type MEMORY_DOCTOR = typeof import('./MEMORY_DOCTOR').default;
type MEMORY_MALLOC_STATS = typeof import('./MEMORY_MALLOC-STATS').default;
type MEMORY_PURGE = typeof import('./MEMORY_PURGE').default;
// type MEMORY_STATS = typeof import('./MEMORY_STATS').default;
type MEMORY_USAGE = typeof import('./MEMORY_USAGE').default;
type MGET = typeof import('./MGET').default;
type MODULE_LIST = typeof import('./MODULE_LIST').default;
type MODULE_LOAD = typeof import('./MODULE_LOAD').default;
type MODULE_UNLOAD = typeof import('./MODULE_UNLOAD').default;
type MOVE = typeof import('./MOVE').default;
type MSET = typeof import('./MSET').default;
type MSETNX = typeof import('./MSETNX').default;
type OBJECT_ENCODING = typeof import('./OBJECT_ENCODING').default;
type OBJECT_FREQ = typeof import('./OBJECT_FREQ').default;
type OBJECT_IDLETIME = typeof import('./OBJECT_IDLETIME').default;
type OBJECT_REFCOUNT = typeof import('./OBJECT_REFCOUNT').default;
type PERSIST = typeof import('./PERSIST').default;
type PEXPIRE = typeof import('./PEXPIRE').default;
type PEXPIREAT = typeof import('./PEXPIREAT').default;
type PEXPIRETIME = typeof import('./PEXPIRETIME').default;
type PFADD = typeof import('./PFADD').default;
type PFCOUNT = typeof import('./PFCOUNT').default;
type PFMERGE = typeof import('./PFMERGE').default;
type PING = typeof import('./PING').default;
type PSETEX = typeof import('./PSETEX').default;
type PTTL = typeof import('./PTTL').default;
type PUBLISH = typeof import('./PUBLISH').default;
type PUBSUB_CHANNELS = typeof import('./PUBSUB_CHANNELS').default;
type PUBSUB_NUMPAT = typeof import('./PUBSUB_NUMPAT').default;
type PUBSUB_NUMSUB = typeof import('./PUBSUB_NUMSUB').default;
type PUBSUB_SHARDCHANNELS = typeof import('./PUBSUB_SHARDCHANNELS').default;
type RANDOMKEY = typeof import('./RANDOMKEY').default;
type READONLY = typeof import('./READONLY').default;
type RENAME = typeof import('./RENAME').default;
type RENAMENX = typeof import('./RENAMENX').default;
type RPOP_COUNT = typeof import('./RPOP_COUNT').default;
type RPOP = typeof import('./RPOP').default;
type RPOPLPUSH = typeof import('./RPOPLPUSH').default;
type RPUSH = typeof import('./RPUSH').default;
type RPUSHX = typeof import('./RPUSHX').default;
type SADD = typeof import('./SADD').default;
type SCAN = typeof import('./SCAN').default;
type SCARD = typeof import('./SCARD').default;
type SCRIPT_DEBUG = typeof import('./SCRIPT_DEBUG').default;
type SCRIPT_EXISTS = typeof import('./SCRIPT_EXISTS').default;
type SCRIPT_FLUSH = typeof import('./SCRIPT_FLUSH').default;
type SCRIPT_KILL = typeof import('./SCRIPT_KILL').default;
type SCRIPT_LOAD = typeof import('./SCRIPT_LOAD').default;
type SDIFF = typeof import('./SDIFF').default;
type SDIFFSTORE = typeof import('./SDIFFSTORE').default;
type SET = typeof import('./SET').default;
type SETBIT = typeof import('./SETBIT').default;
type SETEX = typeof import('./SETEX').default;
type SETNX = typeof import('./SETNX').default;
type SETRANGE = typeof import('./SETRANGE').default;
type SINTER = typeof import('./SINTER').default;
type SINTERCARD = typeof import('./SINTERCARD').default;
type SINTERSTORE = typeof import('./SINTERSTORE').default;
type SISMEMBER = typeof import('./SISMEMBER').default;
type SMEMBERS = typeof import('./SMEMBERS').default;
type SMISMEMBER = typeof import('./SMISMEMBER').default;
type SMOVE = typeof import('./SMOVE').default;
type SORT_RO = typeof import('./SORT_RO').default;
type SORT_STORE = typeof import('./SORT_STORE').default;
type SORT = typeof import('./SORT').default;
type SPOP_COUNT = typeof import('./SPOP_COUNT').default;
type SPOP = typeof import('./SPOP').default;
type SPUBLISH = typeof import('./SPUBLISH').default;
type SRANDMEMBER_COUNT = typeof import('./SRANDMEMBER_COUNT').default;
type SRANDMEMBER = typeof import('./SRANDMEMBER').default;
type SREM = typeof import('./SREM').default;
type SSCAN = typeof import('./SSCAN').default;
type STRLEN = typeof import('./STRLEN').default;
type SUNION = typeof import('./SUNION').default;
type SUNIONSTORE = typeof import('./SUNIONSTORE').default;
type TOUCH = typeof import('./TOUCH').default;
type TTL = typeof import('./TTL').default;
type TYPE = typeof import('./TYPE').default;
type UNLINK = typeof import('./UNLINK').default;
type UNWATCH = typeof import('./UNWATCH').default;
type WAIT = typeof import('./WAIT').default;
type WATCH = typeof import('./WATCH').default;
type XACK = typeof import('./XACK').default;
type XADD_NOMKSTREAM = typeof import('./XADD_NOMKSTREAM').default;
type XADD = typeof import('./XADD').default;
type XDEL = typeof import('./XDEL').default;
type XSETID = typeof import('./XSETID').default;
type XTRIM = typeof import('./XTRIM').default;
type XLEN = typeof import('./XLEN').default;
type ZADD_INCR = typeof import('./ZADD_INCR').default;
type ZADD = typeof import('./ZADD').default;
type ZCARD = typeof import('./ZCARD').default;
type ZCOUNT = typeof import('./ZCOUNT').default;
type ZDIFF_WITHSCORES = typeof import('./ZDIFF_WITHSCORES').default;
type ZDIFF = typeof import('./ZDIFF').default;
type ZDIFFSTORE = typeof import('./ZDIFFSTORE').default;
type ZINCRBY = typeof import('./ZINCRBY').default;
type ZINTER_WITHSCORES = typeof import('./ZINTER_WITHSCORES').default;
type ZINTER = typeof import('./ZINTER').default;
type ZINTERCARD = typeof import('./ZINTERCARD').default;
type ZINTERSTORE = typeof import('./ZINTERSTORE').default;
type ZLEXCOUNT = typeof import('./ZLEXCOUNT').default;
type ZMSCORE = typeof import('./ZMSCORE').default;
type ZRANDMEMBER_COUNT_WITHSCORES = typeof import('./ZRANDMEMBER_COUNT_WITHSCORES').default;
type ZRANDMEMBER_COUNT = typeof import('./ZRANDMEMBER_COUNT').default;
type ZRANDMEMBER = typeof import('./ZRANDMEMBER').default;
type ZRANGE = typeof import('./ZRANGE').default;
type ZRANGEBYLEX = typeof import('./ZRANGEBYLEX').default;
type ZRANGEBYSCORE_WITHSCORES = typeof import('./ZRANGEBYSCORE_WITHSCORES').default;
type ZRANGEBYSCORE = typeof import('./ZRANGEBYSCORE').default;
type ZREMRANGEBYSCORE = typeof import('./ZREMRANGEBYSCORE').default;
type ZRANK = typeof import('./ZRANK').default;
type ZREM = typeof import('./ZREM').default;
type ZREMRANGEBYLEX = typeof import('./ZREMRANGEBYLEX').default;
type ZREMRANGEBYRANK = typeof import('./ZREMRANGEBYRANK').default;
type ZREVRANK = typeof import('./ZREVRANK').default;
type ZSCAN = typeof import('./ZSCAN').default;
type ZSCORE = typeof import('./ZSCORE').default;
type ZUNION_WITHSCORES = typeof import('./ZUNION_WITHSCORES').default;
type ZUNION = typeof import('./ZUNION').default;
type ZUNIONSTORE = typeof import('./ZUNIONSTORE').default;
type Commands = {
ACL_CAT: ACL_CAT;
aclCat: ACL_CAT;
ACL_DRYRUN: ACL_DRYRUN;
aclDryRun: ACL_DRYRUN;
ACL_GENPASS: ACL_GENPASS;
aclGenPass: ACL_GENPASS;
ACL_GETUSER: ACL_GETUSER;
aclGetUser: ACL_GETUSER;
ACL_LIST: ACL_LIST;
aclList: ACL_LIST;
ACL_LOAD: ACL_LOAD;
aclLoad: ACL_LOAD;
ACL_LOG_RESET: ACL_LOG_RESET;
aclLogReset: ACL_LOG_RESET;
ACL_LOG: ACL_LOG;
aclLog: ACL_LOG;
ACL_SAVE: ACL_SAVE;
aclSave: ACL_SAVE;
ACL_SETUSER: ACL_SETUSER;
aclSetUser: ACL_SETUSER;
ACL_USERS: ACL_USERS;
aclUsers: ACL_USERS;
ACL_WHOAMI: ACL_WHOAMI;
aclWhoAmI: ACL_WHOAMI;
APPEND: APPEND;
append: APPEND;
ASKING: ASKING;
asking: ASKING;
AUTH: AUTH;
auth: AUTH;
BGREWRITEAOF: BGREWRITEAOF;
bgRewriteAof: BGREWRITEAOF;
BGSAVE: BGSAVE;
bgSave: BGSAVE;
BITCOUNT: BITCOUNT;
bitCount: BITCOUNT;
BITFIELD_RO: BITFIELD_RO;
bitFieldRo: BITFIELD_RO;
BITFIELD: BITFIELD;
bitField: BITFIELD;
BITOP: BITOP;
bitOp: BITOP;
BITPOS: BITPOS;
bitPos: BITPOS;
BLMOVE: BLMOVE;
blMove: BLMOVE;
BLMPOP: BLMPOP;
blmPop: BLMPOP;
BLPOP: BLPOP;
blPop: BLPOP;
BRPOP: BRPOP;
brPop: BRPOP;
BRPOPLPUSH: BRPOPLPUSH;
brPopLPush: BRPOPLPUSH;
CLIENT_CACHING: CLIENT_CACHING;
clientCaching: CLIENT_CACHING;
CLIENT_GETNAME: CLIENT_GETNAME;
clientGetName: CLIENT_GETNAME;
CLIENT_GETREDIR: CLIENT_GETREDIR;
clientGetRedir: CLIENT_GETREDIR;
CLIENT_ID: CLIENT_ID;
clientId: CLIENT_ID;
CLIENT_INFO: CLIENT_INFO;
clientInfo: CLIENT_INFO;
CLIENT_KILL: CLIENT_KILL;
clientKill: CLIENT_KILL;
CLIENT_LIST: CLIENT_LIST;
clientList: CLIENT_LIST;
'CLIENT_NO-EVICT': CLIENT_NO_EVICT;
clientNoEvict: CLIENT_NO_EVICT;
CLIENT_PAUSE: CLIENT_PAUSE;
clientPause: CLIENT_PAUSE;
CLIENT_SETNAME: CLIENT_SETNAME;
clientSetName: CLIENT_SETNAME;
CLUSTER_ADDSLOTS: CLUSTER_ADDSLOTS;
clusterAddSlots: CLUSTER_ADDSLOTS;
CLUSTER_SLOTS: CLUSTER_SLOTS;
clusterSlots: CLUSTER_SLOTS;
CLUSTER_MEET: CLUSTER_MEET;
clusterMeet: CLUSTER_MEET;
CLUSTER_MYID: CLUSTER_MYID;
clusterMyId: CLUSTER_MYID;
CLUSTER_REPLICATE: CLUSTER_REPLICATE;
clusterReplicate: CLUSTER_REPLICATE;
COPY: COPY;
copy: COPY;
DBSIZE: DBSIZE;
dbSize: DBSIZE;
DECR: DECR;
decr: DECR;
DECRBY: DECRBY;
decrBy: DECRBY;
DEL: DEL;
del: DEL;
DUMP: DUMP;
dump: DUMP;
ECHO: ECHO;
echo: ECHO;
EVAL_RO: EVAL_RO;
evalRo: EVAL_RO;
EVAL: EVAL;
eval: EVAL;
EVALSHA_RO: EVALSHA_RO;
evalShaRo: EVALSHA_RO;
EVALSHA: EVALSHA;
evalSha: EVALSHA;
EXISTS: EXISTS;
exists: EXISTS;
EXPIRE: EXPIRE;
expire: EXPIRE;
EXPIREAT: EXPIREAT;
expireAt: EXPIREAT;
EXPIRETIME: EXPIRETIME;
expireTime: EXPIRETIME;
FLUSHALL: FLUSHALL;
flushAll: FLUSHALL;
FLUSHDB: FLUSHDB;
flushDb: FLUSHDB;
FCALL: FCALL;
fCall: FCALL;
FCALL_RO: FCALL_RO;
fCallRo: FCALL_RO;
FUNCTION_DELETE: FUNCTION_DELETE;
functionDelete: FUNCTION_DELETE;
FUNCTION_DUMP: FUNCTION_DUMP;
functionDump: FUNCTION_DUMP;
FUNCTION_FLUSH: FUNCTION_FLUSH;
functionFlush: FUNCTION_FLUSH;
FUNCTION_KILL: FUNCTION_KILL;
functionKill: FUNCTION_KILL;
FUNCTION_LIST_WITHCODE: FUNCTION_LIST_WITHCODE;
functionListWithCode: FUNCTION_LIST_WITHCODE;
FUNCTION_LIST: FUNCTION_LIST;
functionList: FUNCTION_LIST;
FUNCTION_LOAD: FUNCTION_LOAD;
functionLoad: FUNCTION_LOAD;
// FUNCTION_RESTORE: FUNCTION_RESTORE;
// functionRestore: FUNCTION_RESTORE;
// FUNCTION_STATS: FUNCTION_STATS;
// functionStats: FUNCTION_STATS;
GEOADD: GEOADD;
geoAdd: GEOADD;
GEODIST: GEODIST;
geoDist: GEODIST;
GEOHASH: GEOHASH;
geoHash: GEOHASH;
GEOPOS: GEOPOS;
geoPos: GEOPOS;
GEORADIUS_RO_WITH: GEORADIUS_RO_WITH;
geoRadiusRoWith: GEORADIUS_RO_WITH;
GEORADIUS_RO: GEORADIUS_RO;
geoRadiusRo: GEORADIUS_RO
GEORADIUS_STORE: GEORADIUS_STORE;
geoRadiusStore: GEORADIUS_STORE;
GEORADIUS_WITH: GEORADIUS_WITH;
geoRadiusWith: GEORADIUS_WITH;
GEORADIUS: GEORADIUS;
geoRadius: GEORADIUS;
GEORADIUSBYMEMBER_RO_WITH: GEORADIUSBYMEMBER_RO_WITH;
geoRadiusByMemberRoWith: GEORADIUSBYMEMBER_RO_WITH;
GEORADIUSBYMEMBER_RO: GEORADIUSBYMEMBER_RO;
geoRadiusByMemberRo: GEORADIUSBYMEMBER_RO;
GEORADIUSBYMEMBER_STORE: GEORADIUSBYMEMBER_STORE;
geoRadiusByMemberStore: GEORADIUSBYMEMBER_STORE;
GEORADIUSBYMEMBER_WITH: GEORADIUSBYMEMBER_WITH;
geoRadiusByMemberWith: GEORADIUSBYMEMBER_WITH;
GEORADIUSBYMEMBER: GEORADIUSBYMEMBER;
geoRadiusByMember: GEORADIUSBYMEMBER;
GEOSEARCH_WITH: GEOSEARCH_WITH;
geoSearchWith: GEOSEARCH_WITH;
GEOSEARCH: GEOSEARCH;
geoSearch: GEOSEARCH;
GEOSEARCHSTORE: GEOSEARCHSTORE;
geoSearchStore: GEOSEARCHSTORE;
GET: GET;
get: GET;
GETBIT: GETBIT;
getBit: GETBIT;
GETDEL: GETDEL;
getDel: GETDEL;
GETEX: GETEX;
getEx: GETEX;
GETRANGE: GETRANGE;
getRange: GETRANGE;
GETSET: GETSET;
getSet: GETSET;
HDEL: HDEL;
hDel: HDEL;
HELLO: HELLO;
hello: HELLO;
HEXISTS: HEXISTS;
hExists: HEXISTS;
HGET: HGET;
hGet: HGET;
HGETALL: HGETALL;
hGetAll: HGETALL;
HINCRBY: HINCRBY;
hIncrBy: HINCRBY;
HINCRBYFLOAT: HINCRBYFLOAT;
hIncrByFloat: HINCRBYFLOAT;
HKEYS: HKEYS;
hKeys: HKEYS;
HLEN: HLEN;
hLen: HLEN;
HMGET: HMGET;
hmGet: HMGET;
HRANDFIELD_COUNT_WITHVALUES: HRANDFIELD_COUNT_WITHVALUES;
hRandFieldCountWithValues: HRANDFIELD_COUNT_WITHVALUES;
HRANDFIELD_COUNT: HRANDFIELD_COUNT;
hRandFieldCount: HRANDFIELD_COUNT;
HRANDFIELD: HRANDFIELD;
hRandField: HRANDFIELD;
HSCAN: HSCAN;
hScan: HSCAN;
HSET: HSET;
hSet: HSET;
HSETNX: HSETNX;
hSetNX: HSETNX;
HSTRLEN: HSTRLEN;
hStrLen: HSTRLEN;
HVALS: HVALS;
hVals: HVALS;
INCR: INCR;
incr: INCR;
INCRBY: INCRBY;
incrBy: INCRBY;
INCRBYFLOAT: INCRBYFLOAT;
incrByFloat: INCRBYFLOAT;
INFO: INFO;
info: INFO;
KEYS: KEYS;
keys: KEYS;
LASTSAVE: LASTSAVE;
lastSave: LASTSAVE;
LCS_IDX_WITHMATCHLEN: LCS_IDX_WITHMATCHLEN;
lcsIdxWithMatchLen: LCS_IDX_WITHMATCHLEN;
LCS_IDX: LCS_IDX;
lcsIdx: LCS_IDX;
LCS_LEN: LCS_LEN;
lcsLen: LCS_LEN;
LCS: LCS;
lcs: LCS;
LINDEX: LINDEX;
lIndex: LINDEX;
LINSERT: LINSERT;
lInsert: LINSERT;
LLEN: LLEN;
lLen: LLEN;
LMOVE: LMOVE;
lMove: LMOVE;
LMPOP: LMPOP;
lmPop: LMPOP;
LOLWUT: LOLWUT;
LPOP_COUNT: LPOP_COUNT;
lPopCount: LPOP_COUNT;
LPOP: LPOP;
lPop: LPOP;
LPOS_COUNT: LPOS_COUNT;
lPosCount: LPOS_COUNT;
LPOS: LPOS;
lPos: LPOS;
LPUSH: LPUSH;
lPush: LPUSH;
LPUSHX: LPUSHX;
lPushX: LPUSHX;
LRANGE: LRANGE;
lRange: LRANGE;
LREM: LREM;
lRem: LREM;
LSET: LSET;
lSet: LSET;
LTRIM: LTRIM;
lTrim: LTRIM;
MEMORY_DOCTOR: MEMORY_DOCTOR;
memoryDoctor: MEMORY_DOCTOR;
'MEMORY_MALLOC-STATS': MEMORY_MALLOC_STATS;
memoryMallocStats: MEMORY_MALLOC_STATS;
MEMORY_PURGE: MEMORY_PURGE;
memoryPurge: MEMORY_PURGE;
// MEMORY_STATS: MEMORY_STATS;
// memoryStats: MEMORY_STATS;
MEMORY_USAGE: MEMORY_USAGE;
memoryUsage: MEMORY_USAGE;
MGET: MGET;
mGet: MGET;
MODULE_LIST: MODULE_LIST;
moduleList: MODULE_LIST;
MODULE_LOAD: MODULE_LOAD;
moduleLoad: MODULE_LOAD;
MODULE_UNLOAD: MODULE_UNLOAD;
moduleUnload: MODULE_UNLOAD;
MOVE: MOVE;
move: MOVE;
MSET: MSET;
mSet: MSET;
MSETNX: MSETNX;
mSetNX: MSETNX;
OBJECT_ENCODING: OBJECT_ENCODING;
objectEncoding: OBJECT_ENCODING;
OBJECT_FREQ: OBJECT_FREQ;
objectFreq: OBJECT_FREQ;
OBJECT_IDLETIME: OBJECT_IDLETIME;
objectIdleTime: OBJECT_IDLETIME;
OBJECT_REFCOUNT: OBJECT_REFCOUNT
objectRefCount: OBJECT_REFCOUNT;
PERSIST: PERSIST;
persist: PERSIST;
PEXPIRE: PEXPIRE;
pExpire: PEXPIRE;
PEXPIREAT: PEXPIREAT;
pExpireAt: PEXPIREAT;
PEXPIRETIME: PEXPIRETIME;
pExpireTime: PEXPIRETIME;
PFADD: PFADD;
pfAdd: PFADD;
PFCOUNT: PFCOUNT;
pfCount: PFCOUNT;
PFMERGE: PFMERGE;
pfMerge: PFMERGE;
PING: PING;
/**
* ping jsdoc
*/
ping: PING;
PSETEX: PSETEX;
pSetEx: PSETEX;
PTTL: PTTL;
pTTL: PTTL;
PUBLISH: PUBLISH;
publish: PUBLISH;
PUBSUB_CHANNELS: PUBSUB_CHANNELS;
pubSubChannels: PUBSUB_CHANNELS;
PUBSUB_NUMPAT: PUBSUB_NUMPAT;
pubSubNumPat: PUBSUB_NUMPAT;
PUBSUB_NUMSUB: PUBSUB_NUMSUB;
pubSubNumSub: PUBSUB_NUMSUB;
PUBSUB_SHARDCHANNELS: PUBSUB_SHARDCHANNELS;
pubSubShardChannels: PUBSUB_SHARDCHANNELS;
RANDOMKEY: RANDOMKEY;
randomKey: RANDOMKEY;
READONLY: READONLY;
readonly: READONLY;
RENAME: RENAME;
rename: RENAME;
RENAMENX: RENAMENX;
renameNX: RENAMENX;
RPOP_COUNT: RPOP_COUNT;
rPopCount: RPOP_COUNT;
RPOP: RPOP;
rPop: RPOP;
RPOPLPUSH: RPOPLPUSH;
rPopLPush: RPOPLPUSH;
RPUSH: RPUSH;
rPush: RPUSH;
RPUSHX: RPUSHX;
rPushX: RPUSHX;
SADD: SADD;
sAdd: SADD;
SCAN: SCAN;
scan: SCAN;
SCARD: SCARD;
sCard: SCARD;
SCRIPT_DEBUG: SCRIPT_DEBUG;
scriptDebug: SCRIPT_DEBUG;
SCRIPT_EXISTS: SCRIPT_EXISTS;
scriptExists: SCRIPT_EXISTS;
SCRIPT_FLUSH: SCRIPT_FLUSH;
scriptFlush: SCRIPT_FLUSH;
SCRIPT_KILL: SCRIPT_KILL;
scriptKill: SCRIPT_KILL;
SCRIPT_LOAD: SCRIPT_LOAD;
scriptLoad: SCRIPT_LOAD;
SDIFF: SDIFF;
sDiff: SDIFF;
SDIFFSTORE: SDIFFSTORE;
sDiffStore: SDIFFSTORE;
SET: SET;
set: SET;
SETBIT: SETBIT;
setBit: SETBIT;
SETEX: SETEX;
setEx: SETEX;
SETNX: SETNX;
setNX: SETNX;
SETRANGE: SETRANGE;
setRange: SETRANGE;
SINTER: SINTER;
sInter: SINTER;
SINTERCARD: SINTERCARD;
sInterCard: SINTERCARD;
SINTERSTORE: SINTERSTORE;
sInterStore: SINTERSTORE;
SISMEMBER: SISMEMBER;
sIsMember: SISMEMBER;
SMEMBERS: SMEMBERS;
sMembers: SMEMBERS;
SMISMEMBER: SMISMEMBER;
smIsMember: SMISMEMBER;
SMOVE: SMOVE;
sMove: SMOVE;
SORT_RO: SORT_RO;
sortRo: SORT_RO;
SORT_STORE: SORT_STORE;
sortStore: SORT_STORE;
SORT: SORT;
sort: SORT;
SPOP_COUNT: SPOP_COUNT;
sPopCount: SPOP_COUNT;
SPOP: SPOP;
sPop: SPOP;
SPUBLISH: SPUBLISH;
sPublish: SPUBLISH;
SRANDMEMBER_COUNT: SRANDMEMBER_COUNT;
sRandMemberCount: SRANDMEMBER_COUNT;
SRANDMEMBER: SRANDMEMBER;
sRandMember: SRANDMEMBER;
SREM: SREM;
sRem: SREM;
SSCAN: SSCAN;
sScan: SSCAN;
STRLEN: STRLEN;
strLen: STRLEN;
SUNION: SUNION;
sUnion: SUNION;
SUNIONSTORE: SUNIONSTORE;
sUnionStore: SUNIONSTORE;
TOUCH: TOUCH;
touch: TOUCH;
TTL: TTL;
ttl: TTL;
TYPE: TYPE;
type: TYPE;
UNLINK: UNLINK;
unlink: UNLINK;
UNWATCH: UNWATCH;
unwatch: UNWATCH;
WAIT: WAIT;
wait: WAIT;
WATCH: WATCH;
watch: WATCH;
XACK: XACK;
xAck: XACK;
XADD_NOMKSTREAM: XADD_NOMKSTREAM;
xAddNoMkStream: XADD_NOMKSTREAM;
XADD: XADD;
xAdd: XADD;
XDEL: XDEL;
xDel: XDEL;
XSETID: XSETID;
xSetId: XSETID;
XTRIM: XTRIM;
xTrim: XTRIM;
XLEN: XLEN;
xLen: XLEN;
ZADD_INCR: ZADD_INCR;
zAddIncr: ZADD_INCR;
ZADD: ZADD;
zAdd: ZADD;
ZCARD: ZCARD;
zCard: ZCARD;
ZCOUNT: ZCOUNT;
zCount: ZCOUNT;
ZDIFF_WITHSCORES: ZDIFF_WITHSCORES;
zDiffWithScores: ZDIFF_WITHSCORES;
ZDIFF: ZDIFF;
zDiff: ZDIFF;
ZDIFFSTORE: ZDIFFSTORE;
zDiffStore: ZDIFFSTORE;
ZINCRBY: ZINCRBY;
zIncrBy: ZINCRBY;
ZINTER_WITHSCORES: ZINTER_WITHSCORES;
zInterWithScores: ZINTER_WITHSCORES;
ZINTER: ZINTER;
zInter: ZINTER;
ZINTERCARD: ZINTERCARD;
zInterCard: ZINTERCARD;
ZINTERSTORE: ZINTERSTORE;
zInterStore: ZINTERSTORE;
ZLEXCOUNT: ZLEXCOUNT;
zLexCount: ZLEXCOUNT;
ZMSCORE: ZMSCORE;
zmScore: ZMSCORE;
ZRANDMEMBER_COUNT_WITHSCORES: ZRANDMEMBER_COUNT_WITHSCORES;
zRandMemberCountWithScores: ZRANDMEMBER_COUNT_WITHSCORES;
ZRANDMEMBER_COUNT: ZRANDMEMBER_COUNT;
zRandMemberCount: ZRANDMEMBER_COUNT;
ZRANDMEMBER: ZRANDMEMBER;
zRandMember: ZRANDMEMBER;
ZRANGE: ZRANGE;
zRange: ZRANGE;
ZRANGEBYLEX: ZRANGEBYLEX;
zRangeByLex: ZRANGEBYLEX;
ZRANGEBYSCORE_WITHSCORES: ZRANGEBYSCORE_WITHSCORES;
zRangeByScoreWithScores: ZRANGEBYSCORE_WITHSCORES;
ZRANGEBYSCORE: ZRANGEBYSCORE;
zRangeByScore: ZRANGEBYSCORE;
ZRANK: ZRANK;
zRank: ZRANK;
ZREM: ZREM;
zRem: ZREM;
ZREMRANGEBYLEX: ZREMRANGEBYLEX;
zRemRangeByLex: ZREMRANGEBYLEX;
ZREMRANGEBYRANK: ZREMRANGEBYRANK;
zRemRangeByRank: ZREMRANGEBYRANK;
ZREMRANGEBYSCORE: ZREMRANGEBYSCORE;
zRemRangeByScore: ZREMRANGEBYSCORE;
ZREVRANK: ZREVRANK;
zRevRank: ZREVRANK;
ZSCAN: ZSCAN;
zScan: ZSCAN;
ZSCORE: ZSCORE;
zScore: ZSCORE;
ZUNION_WITHSCORES: ZUNION_WITHSCORES;
zUnionWithScores: ZUNION_WITHSCORES;
ZUNION: ZUNION;
zUnion: ZUNION;
ZUNIONSTORE: ZUNIONSTORE;
zUnionStore: ZUNIONSTORE;
};
export default { export default {
ACL_CAT, ACL_CAT,
aclCat: ACL_CAT, aclCat: ACL_CAT,
@@ -333,6 +1125,8 @@ export default {
clusterReplicate: CLUSTER_REPLICATE, clusterReplicate: CLUSTER_REPLICATE,
COPY, COPY,
copy: COPY, copy: COPY,
DBSIZE,
dbSize: DBSIZE,
DECR, DECR,
decr: DECR, decr: DECR,
DECRBY, DECRBY,
@@ -363,6 +1157,28 @@ export default {
flushAll: FLUSHALL, flushAll: FLUSHALL,
FLUSHDB, FLUSHDB,
flushDb: FLUSHDB, flushDb: FLUSHDB,
FCALL,
fCall: FCALL,
FCALL_RO,
fCallRo: FCALL_RO,
FUNCTION_DELETE,
functionDelete: FUNCTION_DELETE,
FUNCTION_DUMP,
functionDump: FUNCTION_DUMP,
FUNCTION_FLUSH,
functionFlush: FUNCTION_FLUSH,
FUNCTION_KILL,
functionKill: FUNCTION_KILL,
FUNCTION_LIST_WITHCODE,
functionListWithCode: FUNCTION_LIST_WITHCODE,
FUNCTION_LIST,
functionList: FUNCTION_LIST,
FUNCTION_LOAD,
functionLoad: FUNCTION_LOAD,
// FUNCTION_RESTORE,
// functionRestore: FUNCTION_RESTORE,
// FUNCTION_STATS,
// functionStats: FUNCTION_STATS,
GEOADD, GEOADD,
geoAdd: GEOADD, geoAdd: GEOADD,
GEODIST, GEODIST,
@@ -740,5 +1556,5 @@ export default {
ZUNION, ZUNION,
zUnion: ZUNION, zUnion: ZUNION,
ZUNIONSTORE, ZUNIONSTORE,
zUnionStore: ZUNIONSTORE, zUnionStore: ZUNIONSTORE
} as const satisfies Record<string, Command>; } as const satisfies Record<string, Command> as Commands;

View File

@@ -1,6 +1,6 @@
import { createConnection } from 'net'; import { createConnection } from 'net';
import { once } from 'events'; import { once } from 'events';
import { createClient } from '@redis/client'; import { createClient } from '@redis/client/index';
import { setTimeout } from 'timers/promises'; import { setTimeout } from 'timers/promises';
// import { ClusterSlotsReply } from '@redis/client/dist/lib/commands/CLUSTER_SLOTS'; // import { ClusterSlotsReply } from '@redis/client/dist/lib/commands/CLUSTER_SLOTS';
import * as path from 'path'; import * as path from 'path';

View File

@@ -9,7 +9,7 @@ import {
createCluster, createCluster,
RedisClusterOptions, RedisClusterOptions,
RedisClusterType RedisClusterType
} from '@redis/client'; } from '@redis/client/index';
import { RedisServerDockerConfig, spawnRedisServer, spawnRedisCluster } from './dockers'; import { RedisServerDockerConfig, spawnRedisServer, spawnRedisCluster } from './dockers';
import yargs from 'yargs'; import yargs from 'yargs';
import { hideBin } from 'yargs/helpers'; import { hideBin } from 'yargs/helpers';