You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
new "transform arguments" API for better key and metadata extraction (#2733)
* Parser support with all commands * remove "dist" from all imports for consistency * address most of my review comments * small tweak to multi type mapping handling * tweak multi commands / fix addScript cases * nits * addressed all in person review comments * revert addCommand/addScript changes to multi-commands addCommand needs to be there for sendCommand like ability within a multi. If its there, it might as well be used by createCommand() et al, to avoid repeating code. addScript is there (even though only used once), but now made private to keep the logic for bookkeeping near each other.
This commit is contained in:
2511
package-lock.json
generated
2511
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import ADD from './ADD';
|
import ADD from './ADD';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('BF.ADD', () => {
|
describe('BF.ADD', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
ADD.transformArguments('key', 'item'),
|
parseArgs(ADD, 'key', 'item'),
|
||||||
['BF.ADD', 'key', 'item']
|
['BF.ADD', 'key', 'item']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
import { transformBooleanReply } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(key: RedisArgument, item: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument, item: RedisArgument) {
|
||||||
return ['BF.ADD', key, item];
|
parser.push('BF.ADD');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.push(item);
|
||||||
},
|
},
|
||||||
transformReply: transformBooleanReply
|
transformReply: transformBooleanReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import CARD from './CARD';
|
import CARD from './CARD';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('BF.CARD', () => {
|
describe('BF.CARD', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
CARD.transformArguments('bloom'),
|
parseArgs(CARD, 'bloom'),
|
||||||
['BF.CARD', 'bloom']
|
['BF.CARD', 'bloom']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, NumberReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||||
return ['BF.CARD', key];
|
parser.push('BF.CARD');
|
||||||
|
parser.pushKey(key);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => NumberReply
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import EXISTS from './EXISTS';
|
import EXISTS from './EXISTS';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('BF.EXISTS', () => {
|
describe('BF.EXISTS', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
EXISTS.transformArguments('key', 'item'),
|
parseArgs(EXISTS, 'key', 'item'),
|
||||||
['BF.EXISTS', 'key', 'item']
|
['BF.EXISTS', 'key', 'item']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
import { transformBooleanReply } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument, item: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument, item: RedisArgument) {
|
||||||
return ['BF.EXISTS', key, item];
|
parser.push('BF.EXISTS');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.push(item);
|
||||||
},
|
},
|
||||||
transformReply: transformBooleanReply
|
transformReply: transformBooleanReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import INFO from './INFO';
|
import INFO from './INFO';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('BF.INFO', () => {
|
describe('BF.INFO', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INFO.transformArguments('bloom'),
|
parseArgs(INFO, 'bloom'),
|
||||||
['BF.INFO', 'bloom']
|
['BF.INFO', 'bloom']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import { RedisArgument, Command, UnwrapReply, NullReply, NumberReply, TuplesToMapReply, Resp2Reply, SimpleStringReply, TypeMapping } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, Command, UnwrapReply, NullReply, NumberReply, TuplesToMapReply, Resp2Reply, SimpleStringReply, TypeMapping } from '@redis/client/lib/RESP/types';
|
||||||
import { transformInfoV2Reply } from '.';
|
import { transformInfoV2Reply } from '.';
|
||||||
|
|
||||||
export type BfInfoReplyMap = TuplesToMapReply<[
|
export type BfInfoReplyMap = TuplesToMapReply<[
|
||||||
@@ -9,19 +10,11 @@ export type BfInfoReplyMap = TuplesToMapReply<[
|
|||||||
[SimpleStringReply<'Expansion rate'>, NullReply | NumberReply]
|
[SimpleStringReply<'Expansion rate'>, NullReply | NumberReply]
|
||||||
]>;
|
]>;
|
||||||
|
|
||||||
export interface BfInfoReply {
|
|
||||||
capacity: NumberReply;
|
|
||||||
size: NumberReply;
|
|
||||||
numberOfFilters: NumberReply;
|
|
||||||
numberOfInsertedItems: NumberReply;
|
|
||||||
expansionRate: NullReply | NumberReply;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||||
return ['BF.INFO', key];
|
parser.push('BF.INFO');
|
||||||
|
parser.pushKey(key);
|
||||||
},
|
},
|
||||||
transformReply: {
|
transformReply: {
|
||||||
2: (reply: UnwrapReply<Resp2Reply<BfInfoReplyMap>>, _, typeMapping?: TypeMapping): BfInfoReplyMap => {
|
2: (reply: UnwrapReply<Resp2Reply<BfInfoReplyMap>>, _, typeMapping?: TypeMapping): BfInfoReplyMap => {
|
||||||
|
@@ -1,54 +1,55 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import INSERT from './INSERT';
|
import INSERT from './INSERT';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('BF.INSERT', () => {
|
describe('BF.INSERT', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INSERT.transformArguments('key', 'item'),
|
parseArgs(INSERT, 'key', 'item'),
|
||||||
['BF.INSERT', 'key', 'ITEMS', 'item']
|
['BF.INSERT', 'key', 'ITEMS', 'item']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with CAPACITY', () => {
|
it('with CAPACITY', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INSERT.transformArguments('key', 'item', { CAPACITY: 100 }),
|
parseArgs(INSERT, 'key', 'item', { CAPACITY: 100 }),
|
||||||
['BF.INSERT', 'key', 'CAPACITY', '100', 'ITEMS', 'item']
|
['BF.INSERT', 'key', 'CAPACITY', '100', 'ITEMS', 'item']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with ERROR', () => {
|
it('with ERROR', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INSERT.transformArguments('key', 'item', { ERROR: 0.01 }),
|
parseArgs(INSERT, 'key', 'item', { ERROR: 0.01 }),
|
||||||
['BF.INSERT', 'key', 'ERROR', '0.01', 'ITEMS', 'item']
|
['BF.INSERT', 'key', 'ERROR', '0.01', 'ITEMS', 'item']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with EXPANSION', () => {
|
it('with EXPANSION', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INSERT.transformArguments('key', 'item', { EXPANSION: 1 }),
|
parseArgs(INSERT, 'key', 'item', { EXPANSION: 1 }),
|
||||||
['BF.INSERT', 'key', 'EXPANSION', '1', 'ITEMS', 'item']
|
['BF.INSERT', 'key', 'EXPANSION', '1', 'ITEMS', 'item']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with NOCREATE', () => {
|
it('with NOCREATE', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INSERT.transformArguments('key', 'item', { NOCREATE: true }),
|
parseArgs(INSERT, 'key', 'item', { NOCREATE: true }),
|
||||||
['BF.INSERT', 'key', 'NOCREATE', 'ITEMS', 'item']
|
['BF.INSERT', 'key', 'NOCREATE', 'ITEMS', 'item']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with NONSCALING', () => {
|
it('with NONSCALING', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INSERT.transformArguments('key', 'item', { NONSCALING: true }),
|
parseArgs(INSERT, 'key', 'item', { NONSCALING: true }),
|
||||||
['BF.INSERT', 'key', 'NONSCALING', 'ITEMS', 'item']
|
['BF.INSERT', 'key', 'NONSCALING', 'ITEMS', 'item']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with CAPACITY, ERROR, EXPANSION, NOCREATE and NONSCALING', () => {
|
it('with CAPACITY, ERROR, EXPANSION, NOCREATE and NONSCALING', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INSERT.transformArguments('key', 'item', {
|
parseArgs(INSERT, 'key', 'item', {
|
||||||
CAPACITY: 100,
|
CAPACITY: 100,
|
||||||
ERROR: 0.01,
|
ERROR: 0.01,
|
||||||
EXPANSION: 1,
|
EXPANSION: 1,
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||||
import { transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisVariadicArgument } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
import { transformBooleanArrayReply } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export interface BfInsertOptions {
|
export interface BfInsertOptions {
|
||||||
CAPACITY?: number;
|
CAPACITY?: number;
|
||||||
@@ -11,37 +12,38 @@ export interface BfInsertOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(
|
parseCommand(
|
||||||
|
parser: CommandParser,
|
||||||
key: RedisArgument,
|
key: RedisArgument,
|
||||||
items: RedisVariadicArgument,
|
items: RedisVariadicArgument,
|
||||||
options?: BfInsertOptions
|
options?: BfInsertOptions
|
||||||
) {
|
) {
|
||||||
const args = ['BF.INSERT', key];
|
parser.push('BF.INSERT');
|
||||||
|
parser.pushKey(key);
|
||||||
|
|
||||||
if (options?.CAPACITY !== undefined) {
|
if (options?.CAPACITY !== undefined) {
|
||||||
args.push('CAPACITY', options.CAPACITY.toString());
|
parser.push('CAPACITY', options.CAPACITY.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.ERROR !== undefined) {
|
if (options?.ERROR !== undefined) {
|
||||||
args.push('ERROR', options.ERROR.toString());
|
parser.push('ERROR', options.ERROR.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.EXPANSION !== undefined) {
|
if (options?.EXPANSION !== undefined) {
|
||||||
args.push('EXPANSION', options.EXPANSION.toString());
|
parser.push('EXPANSION', options.EXPANSION.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.NOCREATE) {
|
if (options?.NOCREATE) {
|
||||||
args.push('NOCREATE');
|
parser.push('NOCREATE');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.NONSCALING) {
|
if (options?.NONSCALING) {
|
||||||
args.push('NONSCALING');
|
parser.push('NONSCALING');
|
||||||
}
|
}
|
||||||
|
|
||||||
args.push('ITEMS');
|
parser.push('ITEMS');
|
||||||
return pushVariadicArguments(args, items);
|
parser.pushVariadic(items);
|
||||||
},
|
},
|
||||||
transformReply: transformBooleanArrayReply
|
transformReply: transformBooleanArrayReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -2,11 +2,12 @@ import { strict as assert } from 'node:assert';
|
|||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import LOADCHUNK from './LOADCHUNK';
|
import LOADCHUNK from './LOADCHUNK';
|
||||||
import { RESP_TYPES } from '@redis/client';
|
import { RESP_TYPES } from '@redis/client';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('BF.LOADCHUNK', () => {
|
describe('BF.LOADCHUNK', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
LOADCHUNK.transformArguments('key', 0, ''),
|
parseArgs(LOADCHUNK, 'key', 0, ''),
|
||||||
['BF.LOADCHUNK', 'key', '0', '']
|
['BF.LOADCHUNK', 'key', '0', '']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(key: RedisArgument, iterator: number, chunk: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument, iterator: number, chunk: RedisArgument) {
|
||||||
return ['BF.LOADCHUNK', key, iterator.toString(), chunk];
|
parser.push('BF.LOADCHUNK');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.push(iterator.toString(), chunk);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import MADD from './MADD';
|
import MADD from './MADD';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('BF.MADD', () => {
|
describe('BF.MADD', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
MADD.transformArguments('key', ['1', '2']),
|
parseArgs(MADD, 'key', ['1', '2']),
|
||||||
['BF.MADD', 'key', '1', '2']
|
['BF.MADD', 'key', '1', '2']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,12 +1,14 @@
|
|||||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||||
import { transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisVariadicArgument } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
import { transformBooleanArrayReply } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(key: RedisArgument, items: RedisVariadicArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument, items: RedisVariadicArgument) {
|
||||||
return pushVariadicArguments(['BF.MADD', key], items);
|
parser.push('BF.MADD');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.pushVariadic(items);
|
||||||
},
|
},
|
||||||
transformReply: transformBooleanArrayReply
|
transformReply: transformBooleanArrayReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import MEXISTS from './MEXISTS';
|
import MEXISTS from './MEXISTS';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('BF.MEXISTS', () => {
|
describe('BF.MEXISTS', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
MEXISTS.transformArguments('key', ['1', '2']),
|
parseArgs(MEXISTS, 'key', ['1', '2']),
|
||||||
['BF.MEXISTS', 'key', '1', '2']
|
['BF.MEXISTS', 'key', '1', '2']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,12 +1,14 @@
|
|||||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||||
import { transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisVariadicArgument } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
import { transformBooleanArrayReply } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument, items: RedisVariadicArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument, items: RedisVariadicArgument) {
|
||||||
return pushVariadicArguments(['BF.MEXISTS', key], items);
|
parser.push('BF.MEXISTS');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.pushVariadic(items);
|
||||||
},
|
},
|
||||||
transformReply: transformBooleanArrayReply
|
transformReply: transformBooleanArrayReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,19 +1,20 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import RESERVE from './RESERVE';
|
import RESERVE from './RESERVE';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('BF.RESERVE', () => {
|
describe('BF.RESERVE', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
RESERVE.transformArguments('key', 0.01, 100),
|
parseArgs(RESERVE, 'key', 0.01, 100),
|
||||||
['BF.RESERVE', 'key', '0.01', '100']
|
['BF.RESERVE', 'key', '0.01', '100']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with EXPANSION', () => {
|
it('with EXPANSION', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
RESERVE.transformArguments('key', 0.01, 100, {
|
parseArgs(RESERVE, 'key', 0.01, 100, {
|
||||||
EXPANSION: 1
|
EXPANSION: 1
|
||||||
}),
|
}),
|
||||||
['BF.RESERVE', 'key', '0.01', '100', 'EXPANSION', '1']
|
['BF.RESERVE', 'key', '0.01', '100', 'EXPANSION', '1']
|
||||||
@@ -22,7 +23,7 @@ describe('BF.RESERVE', () => {
|
|||||||
|
|
||||||
it('with NONSCALING', () => {
|
it('with NONSCALING', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
RESERVE.transformArguments('key', 0.01, 100, {
|
parseArgs(RESERVE, 'key', 0.01, 100, {
|
||||||
NONSCALING: true
|
NONSCALING: true
|
||||||
}),
|
}),
|
||||||
['BF.RESERVE', 'key', '0.01', '100', 'NONSCALING']
|
['BF.RESERVE', 'key', '0.01', '100', 'NONSCALING']
|
||||||
@@ -31,7 +32,7 @@ describe('BF.RESERVE', () => {
|
|||||||
|
|
||||||
it('with EXPANSION and NONSCALING', () => {
|
it('with EXPANSION and NONSCALING', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
RESERVE.transformArguments('key', 0.01, 100, {
|
parseArgs(RESERVE, 'key', 0.01, 100, {
|
||||||
EXPANSION: 1,
|
EXPANSION: 1,
|
||||||
NONSCALING: true
|
NONSCALING: true
|
||||||
}),
|
}),
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export interface BfReserveOptions {
|
export interface BfReserveOptions {
|
||||||
EXPANSION?: number;
|
EXPANSION?: number;
|
||||||
@@ -6,25 +7,25 @@ export interface BfReserveOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(
|
parseCommand(
|
||||||
|
parser: CommandParser,
|
||||||
key: RedisArgument,
|
key: RedisArgument,
|
||||||
errorRate: number,
|
errorRate: number,
|
||||||
capacity: number,
|
capacity: number,
|
||||||
options?: BfReserveOptions
|
options?: BfReserveOptions
|
||||||
) {
|
) {
|
||||||
const args = ['BF.RESERVE', key, errorRate.toString(), capacity.toString()];
|
parser.push('BF.RESERVE');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.push(errorRate.toString(), capacity.toString());
|
||||||
|
|
||||||
if (options?.EXPANSION) {
|
if (options?.EXPANSION) {
|
||||||
args.push('EXPANSION', options.EXPANSION.toString());
|
parser.push('EXPANSION', options.EXPANSION.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.NONSCALING) {
|
if (options?.NONSCALING) {
|
||||||
args.push('NONSCALING');
|
parser.push('NONSCALING');
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import SCANDUMP from './SCANDUMP';
|
import SCANDUMP from './SCANDUMP';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('BF.SCANDUMP', () => {
|
describe('BF.SCANDUMP', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
SCANDUMP.transformArguments('key', 0),
|
parseArgs(SCANDUMP, 'key', 0),
|
||||||
['BF.SCANDUMP', 'key', '0']
|
['BF.SCANDUMP', 'key', '0']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
import { RedisArgument, TuplesReply, NumberReply, BlobStringReply, UnwrapReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, TuplesReply, NumberReply, BlobStringReply, UnwrapReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument, iterator: number) {
|
parseCommand(parser: CommandParser, key: RedisArgument, iterator: number) {
|
||||||
return ['BF.SCANDUMP', key, iterator.toString()];
|
parser.push('BF.SCANDUMP');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.push(iterator.toString());
|
||||||
},
|
},
|
||||||
transformReply(reply: UnwrapReply<TuplesReply<[NumberReply, BlobStringReply]>>) {
|
transformReply(reply: UnwrapReply<TuplesReply<[NumberReply, BlobStringReply]>>) {
|
||||||
return {
|
return {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import type { RedisCommands, TypeMapping } from '@redis/client/dist/lib/RESP/types';
|
import type { RedisCommands, TypeMapping } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
import ADD from './ADD';
|
import ADD from './ADD';
|
||||||
import CARD from './CARD';
|
import CARD from './CARD';
|
||||||
|
@@ -1,12 +1,13 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import INCRBY from './INCRBY';
|
import INCRBY from './INCRBY';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('CMS.INCRBY', () => {
|
describe('CMS.INCRBY', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('single item', () => {
|
it('single item', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INCRBY.transformArguments('key', {
|
parseArgs(INCRBY, 'key', {
|
||||||
item: 'item',
|
item: 'item',
|
||||||
incrementBy: 1
|
incrementBy: 1
|
||||||
}),
|
}),
|
||||||
@@ -16,7 +17,7 @@ describe('CMS.INCRBY', () => {
|
|||||||
|
|
||||||
it('multiple items', () => {
|
it('multiple items', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INCRBY.transformArguments('key', [{
|
parseArgs(INCRBY, 'key', [{
|
||||||
item: 'a',
|
item: 'a',
|
||||||
incrementBy: 1
|
incrementBy: 1
|
||||||
}, {
|
}, {
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import { RedisArgument, ArrayReply, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, ArrayReply, NumberReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export interface BfIncrByItem {
|
export interface BfIncrByItem {
|
||||||
item: RedisArgument;
|
item: RedisArgument;
|
||||||
@@ -6,27 +7,26 @@ export interface BfIncrByItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(
|
parseCommand(
|
||||||
|
parser: CommandParser,
|
||||||
key: RedisArgument,
|
key: RedisArgument,
|
||||||
items: BfIncrByItem | Array<BfIncrByItem>
|
items: BfIncrByItem | Array<BfIncrByItem>
|
||||||
) {
|
) {
|
||||||
const args = ['CMS.INCRBY', key];
|
parser.push('CMS.INCRBY');
|
||||||
|
parser.pushKey(key);
|
||||||
|
|
||||||
if (Array.isArray(items)) {
|
if (Array.isArray(items)) {
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
pushIncrByItem(args, item);
|
pushIncrByItem(parser, item);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pushIncrByItem(args, items);
|
pushIncrByItem(parser, items);
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => ArrayReply<NumberReply>
|
transformReply: undefined as unknown as () => ArrayReply<NumberReply>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
|
||||||
function pushIncrByItem(args: Array<RedisArgument>, { item, incrementBy }: BfIncrByItem): void {
|
function pushIncrByItem(parser: CommandParser, { item, incrementBy }: BfIncrByItem): void {
|
||||||
args.push(item, incrementBy.toString());
|
parser.push(item, incrementBy.toString());
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import INFO from './INFO';
|
import INFO from './INFO';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('CMS.INFO', () => {
|
describe('CMS.INFO', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INFO.transformArguments('key'),
|
parseArgs(INFO, 'key'),
|
||||||
['CMS.INFO', 'key']
|
['CMS.INFO', 'key']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import { RedisArgument, TuplesToMapReply, NumberReply, UnwrapReply, Resp2Reply, Command, SimpleStringReply, TypeMapping } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, TuplesToMapReply, NumberReply, UnwrapReply, Resp2Reply, Command, SimpleStringReply, TypeMapping } from '@redis/client/lib/RESP/types';
|
||||||
import { transformInfoV2Reply } from '../bloom';
|
import { transformInfoV2Reply } from '../bloom';
|
||||||
|
|
||||||
export type CmsInfoReplyMap = TuplesToMapReply<[
|
export type CmsInfoReplyMap = TuplesToMapReply<[
|
||||||
@@ -14,10 +15,10 @@ export interface CmsInfoReply {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||||
return ['CMS.INFO', key];
|
parser.push('CMS.INFO');
|
||||||
|
parser.pushKey(key);
|
||||||
},
|
},
|
||||||
transformReply: {
|
transformReply: {
|
||||||
2: (reply: UnwrapReply<Resp2Reply<CmsInfoReplyMap>>, _, typeMapping?: TypeMapping): CmsInfoReply => {
|
2: (reply: UnwrapReply<Resp2Reply<CmsInfoReplyMap>>, _, typeMapping?: TypeMapping): CmsInfoReply => {
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import INITBYDIM from './INITBYDIM';
|
import INITBYDIM from './INITBYDIM';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('CMS.INITBYDIM', () => {
|
describe('CMS.INITBYDIM', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INITBYDIM.transformArguments('key', 1000, 5),
|
parseArgs(INITBYDIM, 'key', 1000, 5),
|
||||||
['CMS.INITBYDIM', 'key', '1000', '5']
|
['CMS.INITBYDIM', 'key', '1000', '5']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(key: RedisArgument, width: number, depth: number) {
|
parseCommand(parser: CommandParser, key: RedisArgument, width: number, depth: number) {
|
||||||
return ['CMS.INITBYDIM', key, width.toString(), depth.toString()];
|
parser.push('CMS.INITBYDIM');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.push(width.toString(), depth.toString());
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import INITBYPROB from './INITBYPROB';
|
import INITBYPROB from './INITBYPROB';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('CMS.INITBYPROB', () => {
|
describe('CMS.INITBYPROB', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INITBYPROB.transformArguments('key', 0.001, 0.01),
|
parseArgs(INITBYPROB, 'key', 0.001, 0.01),
|
||||||
['CMS.INITBYPROB', 'key', '0.001', '0.01']
|
['CMS.INITBYPROB', 'key', '0.001', '0.01']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(key: RedisArgument, error: number, probability: number) {
|
parseCommand(parser: CommandParser, key: RedisArgument, error: number, probability: number) {
|
||||||
return ['CMS.INITBYPROB', key, error.toString(), probability.toString()];
|
parser.push('CMS.INITBYPROB');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.push(error.toString(), probability.toString());
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,19 +1,20 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import MERGE from './MERGE';
|
import MERGE from './MERGE';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('CMS.MERGE', () => {
|
describe('CMS.MERGE', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('without WEIGHTS', () => {
|
it('without WEIGHTS', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
MERGE.transformArguments('destination', ['source']),
|
parseArgs(MERGE, 'destination', ['source']),
|
||||||
['CMS.MERGE', 'destination', '1', 'source']
|
['CMS.MERGE', 'destination', '1', 'source']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with WEIGHTS', () => {
|
it('with WEIGHTS', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
MERGE.transformArguments('destination', [{
|
parseArgs(MERGE, 'destination', [{
|
||||||
name: 'source',
|
name: 'source',
|
||||||
weight: 1
|
weight: 1
|
||||||
}]),
|
}]),
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
interface BfMergeSketch {
|
interface BfMergeSketch {
|
||||||
name: RedisArgument;
|
name: RedisArgument;
|
||||||
@@ -8,26 +9,27 @@ interface BfMergeSketch {
|
|||||||
export type BfMergeSketches = Array<RedisArgument> | Array<BfMergeSketch>;
|
export type BfMergeSketches = Array<RedisArgument> | Array<BfMergeSketch>;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(
|
parseCommand(
|
||||||
|
parser: CommandParser,
|
||||||
destination: RedisArgument,
|
destination: RedisArgument,
|
||||||
source: BfMergeSketches
|
source: BfMergeSketches
|
||||||
) {
|
) {
|
||||||
let args = ['CMS.MERGE', destination, source.length.toString()];
|
parser.push('CMS.MERGE');
|
||||||
|
parser.pushKey(destination);
|
||||||
|
parser.push(source.length.toString());
|
||||||
|
|
||||||
if (isPlainSketches(source)) {
|
if (isPlainSketches(source)) {
|
||||||
args = args.concat(source);
|
parser.pushVariadic(source);
|
||||||
} else {
|
} else {
|
||||||
const { length } = args;
|
|
||||||
args[length + source.length] = 'WEIGHTS';
|
|
||||||
for (let i = 0; i < source.length; i++) {
|
for (let i = 0; i < source.length; i++) {
|
||||||
args[length + i] = source[i].name;
|
parser.push(source[i].name);
|
||||||
args[length + source.length + i + 1] = source[i].weight.toString();
|
}
|
||||||
|
parser.push('WEIGHTS');
|
||||||
|
for (let i = 0; i < source.length; i++) {
|
||||||
|
parser.push(source[i].weight.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import QUERY from './QUERY';
|
import QUERY from './QUERY';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('CMS.QUERY', () => {
|
describe('CMS.QUERY', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
QUERY.transformArguments('key', 'item'),
|
parseArgs(QUERY, 'key', 'item'),
|
||||||
['CMS.QUERY', 'key', 'item']
|
['CMS.QUERY', 'key', 'item']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
import { ArrayReply, NumberReply, Command, RedisArgument } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { ArrayReply, NumberReply, Command, RedisArgument } from '@redis/client/lib/RESP/types';
|
||||||
|
import { RedisVariadicArgument } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument, items: RedisVariadicArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument, items: RedisVariadicArgument) {
|
||||||
return pushVariadicArguments(['CMS.QUERY', key], items);
|
parser.push('CMS.QUERY');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.pushVariadic(items);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => ArrayReply<NumberReply>
|
transformReply: undefined as unknown as () => ArrayReply<NumberReply>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import type { RedisCommands } from '@redis/client/dist/lib/RESP/types';
|
import type { RedisCommands } from '@redis/client/lib/RESP/types';
|
||||||
import INCRBY from './INCRBY';
|
import INCRBY from './INCRBY';
|
||||||
import INFO from './INFO';
|
import INFO from './INFO';
|
||||||
import INITBYDIM from './INITBYDIM';
|
import INITBYDIM from './INITBYDIM';
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import ADD from './ADD';
|
import ADD from './ADD';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('CF.ADD', () => {
|
describe('CF.ADD', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
ADD.transformArguments('key', 'item'),
|
parseArgs(ADD, 'key', 'item'),
|
||||||
['CF.ADD', 'key', 'item']
|
['CF.ADD', 'key', 'item']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
import { transformBooleanReply } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(key: RedisArgument, item: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument, item: RedisArgument) {
|
||||||
return ['CF.ADD', key, item];
|
parser.push('CF.ADD');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.push(item);
|
||||||
},
|
},
|
||||||
transformReply: transformBooleanReply
|
transformReply: transformBooleanReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import ADDNX from './ADDNX';
|
import ADDNX from './ADDNX';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('CF.ADDNX', () => {
|
describe('CF.ADDNX', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
ADDNX.transformArguments('key', 'item'),
|
parseArgs(ADDNX, 'key', 'item'),
|
||||||
['CF.ADDNX', 'key', 'item']
|
['CF.ADDNX', 'key', 'item']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
import { transformBooleanReply } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(key: RedisArgument, item: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument, item: RedisArgument) {
|
||||||
return ['CF.ADDNX', key, item];
|
parser.push('CF.ADDNX');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.push(item);
|
||||||
},
|
},
|
||||||
transformReply: transformBooleanReply
|
transformReply: transformBooleanReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import COUNT from './COUNT';
|
import COUNT from './COUNT';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('CF.COUNT', () => {
|
describe('CF.COUNT', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
COUNT.transformArguments('key', 'item'),
|
parseArgs(COUNT, 'key', 'item'),
|
||||||
['CF.COUNT', 'key', 'item']
|
['CF.COUNT', 'key', 'item']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, NumberReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument, item: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument, item: RedisArgument) {
|
||||||
return ['CF.COUNT', key, item];
|
parser.push('CF.COUNT');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.push(item);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => NumberReply
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import DEL from './DEL';
|
import DEL from './DEL';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('CF.DEL', () => {
|
describe('CF.DEL', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
DEL.transformArguments('key', 'item'),
|
parseArgs(DEL, 'key', 'item'),
|
||||||
['CF.DEL', 'key', 'item']
|
['CF.DEL', 'key', 'item']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
import { transformBooleanReply } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(key: RedisArgument, item: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument, item: RedisArgument) {
|
||||||
return ['CF.DEL', key, item];
|
parser.push('CF.DEL');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.push(item);
|
||||||
},
|
},
|
||||||
transformReply: transformBooleanReply
|
transformReply: transformBooleanReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import EXISTS from './EXISTS';
|
import EXISTS from './EXISTS';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('CF.EXISTS', () => {
|
describe('CF.EXISTS', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
EXISTS.transformArguments('key', 'item'),
|
parseArgs(EXISTS, 'key', 'item'),
|
||||||
['CF.EXISTS', 'key', 'item']
|
['CF.EXISTS', 'key', 'item']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
import { transformBooleanReply } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(key: RedisArgument, item: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument, item: RedisArgument) {
|
||||||
return ['CF.EXISTS', key, item];
|
parser.push('CF.EXISTS');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.push(item);
|
||||||
},
|
},
|
||||||
transformReply: transformBooleanReply
|
transformReply: transformBooleanReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import INFO from './INFO';
|
import INFO from './INFO';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('CF.INFO', () => {
|
describe('CF.INFO', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INFO.transformArguments('cuckoo'),
|
parseArgs(INFO, 'cuckoo'),
|
||||||
['CF.INFO', 'cuckoo']
|
['CF.INFO', 'cuckoo']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import { RedisArgument, Command, NumberReply, TuplesToMapReply, UnwrapReply, Resp2Reply, SimpleStringReply, TypeMapping } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, Command, NumberReply, TuplesToMapReply, UnwrapReply, Resp2Reply, SimpleStringReply, TypeMapping } from '@redis/client/lib/RESP/types';
|
||||||
import { transformInfoV2Reply } from '../bloom';
|
import { transformInfoV2Reply } from '../bloom';
|
||||||
|
|
||||||
export type CfInfoReplyMap = TuplesToMapReply<[
|
export type CfInfoReplyMap = TuplesToMapReply<[
|
||||||
@@ -13,10 +14,10 @@ export type CfInfoReplyMap = TuplesToMapReply<[
|
|||||||
]>;
|
]>;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||||
return ['CF.INFO', key];
|
parser.push('CF.INFO');
|
||||||
|
parser.pushKey(key);
|
||||||
},
|
},
|
||||||
transformReply: {
|
transformReply: {
|
||||||
2: (reply: UnwrapReply<Resp2Reply<CfInfoReplyMap>>, _, typeMapping?: TypeMapping): CfInfoReplyMap => {
|
2: (reply: UnwrapReply<Resp2Reply<CfInfoReplyMap>>, _, typeMapping?: TypeMapping): CfInfoReplyMap => {
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import INSERT from './INSERT';
|
import INSERT from './INSERT';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('CF.INSERT', () => {
|
describe('CF.INSERT', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INSERT.transformArguments('key', 'item', {
|
parseArgs(INSERT, 'key', 'item', {
|
||||||
CAPACITY: 100,
|
CAPACITY: 100,
|
||||||
NOCREATE: true
|
NOCREATE: true
|
||||||
}),
|
}),
|
||||||
|
@@ -1,34 +1,37 @@
|
|||||||
import { Command, RedisArgument } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { RedisVariadicArgument, pushVariadicArguments, transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { Command, RedisArgument } from '@redis/client/lib/RESP/types';
|
||||||
|
import { RedisVariadicArgument, transformBooleanArrayReply } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export interface CfInsertOptions {
|
export interface CfInsertOptions {
|
||||||
CAPACITY?: number;
|
CAPACITY?: number;
|
||||||
NOCREATE?: boolean;
|
NOCREATE?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function transofrmCfInsertArguments(
|
export function parseCfInsertArguments(
|
||||||
command: RedisArgument,
|
parser: CommandParser,
|
||||||
key: RedisArgument,
|
key: RedisArgument,
|
||||||
items: RedisVariadicArgument,
|
items: RedisVariadicArgument,
|
||||||
options?: CfInsertOptions
|
options?: CfInsertOptions
|
||||||
) {
|
) {
|
||||||
const args = [command, key];
|
parser.pushKey(key);
|
||||||
|
|
||||||
if (options?.CAPACITY !== undefined) {
|
if (options?.CAPACITY !== undefined) {
|
||||||
args.push('CAPACITY', options.CAPACITY.toString());
|
parser.push('CAPACITY', options.CAPACITY.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.NOCREATE) {
|
if (options?.NOCREATE) {
|
||||||
args.push('NOCREATE');
|
parser.push('NOCREATE');
|
||||||
}
|
}
|
||||||
|
|
||||||
args.push('ITEMS');
|
parser.push('ITEMS');
|
||||||
return pushVariadicArguments(args, items);
|
parser.pushVariadic(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments: transofrmCfInsertArguments.bind(undefined, 'CF.INSERT'),
|
parseCommand(...args: Parameters<typeof parseCfInsertArguments>) {
|
||||||
|
args[0].push('CF.INSERT');
|
||||||
|
parseCfInsertArguments(...args);
|
||||||
|
},
|
||||||
transformReply: transformBooleanArrayReply
|
transformReply: transformBooleanArrayReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import INSERTNX from './INSERTNX';
|
import INSERTNX from './INSERTNX';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('CF.INSERTNX', () => {
|
describe('CF.INSERTNX', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INSERTNX.transformArguments('key', 'item', {
|
parseArgs(INSERTNX, 'key', 'item', {
|
||||||
CAPACITY: 100,
|
CAPACITY: 100,
|
||||||
NOCREATE: true
|
NOCREATE: true
|
||||||
}),
|
}),
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
import { Command } from '@redis/client/dist/lib/RESP/types';
|
import { Command } from '@redis/client/lib/RESP/types';
|
||||||
import INSERT, { transofrmCfInsertArguments } from './INSERT';
|
import INSERT, { parseCfInsertArguments } from './INSERT';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: INSERT.FIRST_KEY_INDEX,
|
|
||||||
IS_READ_ONLY: INSERT.IS_READ_ONLY,
|
IS_READ_ONLY: INSERT.IS_READ_ONLY,
|
||||||
transformArguments: transofrmCfInsertArguments.bind(undefined, 'CF.INSERTNX'),
|
parseCommand(...args: Parameters<typeof parseCfInsertArguments>) {
|
||||||
|
args[0].push('CF.INSERTNX');
|
||||||
|
parseCfInsertArguments(...args);
|
||||||
|
},
|
||||||
transformReply: INSERT.transformReply
|
transformReply: INSERT.transformReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -2,11 +2,12 @@ import { strict as assert } from 'node:assert';
|
|||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import LOADCHUNK from './LOADCHUNK';
|
import LOADCHUNK from './LOADCHUNK';
|
||||||
import { RESP_TYPES } from '@redis/client';
|
import { RESP_TYPES } from '@redis/client';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('CF.LOADCHUNK', () => {
|
describe('CF.LOADCHUNK', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
LOADCHUNK.transformArguments('item', 0, ''),
|
parseArgs(LOADCHUNK, 'item', 0, ''),
|
||||||
['CF.LOADCHUNK', 'item', '0', '']
|
['CF.LOADCHUNK', 'item', '0', '']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
import { SimpleStringReply, Command, RedisArgument } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { SimpleStringReply, Command, RedisArgument } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(key: RedisArgument, iterator: number, chunk: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument, iterator: number, chunk: RedisArgument) {
|
||||||
return ['CF.LOADCHUNK', key, iterator.toString(), chunk];
|
parser.push('CF.LOADCHUNK');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.push(iterator.toString(), chunk);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,19 +1,20 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import RESERVE from './RESERVE';
|
import RESERVE from './RESERVE';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('CF.RESERVE', () => {
|
describe('CF.RESERVE', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
RESERVE.transformArguments('key', 4),
|
parseArgs(RESERVE, 'key', 4),
|
||||||
['CF.RESERVE', 'key', '4']
|
['CF.RESERVE', 'key', '4']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with EXPANSION', () => {
|
it('with EXPANSION', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
RESERVE.transformArguments('key', 4, {
|
parseArgs(RESERVE, 'key', 4, {
|
||||||
EXPANSION: 1
|
EXPANSION: 1
|
||||||
}),
|
}),
|
||||||
['CF.RESERVE', 'key', '4', 'EXPANSION', '1']
|
['CF.RESERVE', 'key', '4', 'EXPANSION', '1']
|
||||||
@@ -22,7 +23,7 @@ describe('CF.RESERVE', () => {
|
|||||||
|
|
||||||
it('with BUCKETSIZE', () => {
|
it('with BUCKETSIZE', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
RESERVE.transformArguments('key', 4, {
|
parseArgs(RESERVE, 'key', 4, {
|
||||||
BUCKETSIZE: 2
|
BUCKETSIZE: 2
|
||||||
}),
|
}),
|
||||||
['CF.RESERVE', 'key', '4', 'BUCKETSIZE', '2']
|
['CF.RESERVE', 'key', '4', 'BUCKETSIZE', '2']
|
||||||
@@ -31,7 +32,7 @@ describe('CF.RESERVE', () => {
|
|||||||
|
|
||||||
it('with MAXITERATIONS', () => {
|
it('with MAXITERATIONS', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
RESERVE.transformArguments('key', 4, {
|
parseArgs(RESERVE, 'key', 4, {
|
||||||
MAXITERATIONS: 1
|
MAXITERATIONS: 1
|
||||||
}),
|
}),
|
||||||
['CF.RESERVE', 'key', '4', 'MAXITERATIONS', '1']
|
['CF.RESERVE', 'key', '4', 'MAXITERATIONS', '1']
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export interface CfReserveOptions {
|
export interface CfReserveOptions {
|
||||||
BUCKETSIZE?: number;
|
BUCKETSIZE?: number;
|
||||||
@@ -7,28 +8,28 @@ export interface CfReserveOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(
|
parseCommand(
|
||||||
|
parser: CommandParser,
|
||||||
key: RedisArgument,
|
key: RedisArgument,
|
||||||
capacity: number,
|
capacity: number,
|
||||||
options?: CfReserveOptions
|
options?: CfReserveOptions
|
||||||
) {
|
) {
|
||||||
const args = ['CF.RESERVE', key, capacity.toString()];
|
parser.push('CF.RESERVE');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.push(capacity.toString());
|
||||||
|
|
||||||
if (options?.BUCKETSIZE !== undefined) {
|
if (options?.BUCKETSIZE !== undefined) {
|
||||||
args.push('BUCKETSIZE', options.BUCKETSIZE.toString());
|
parser.push('BUCKETSIZE', options.BUCKETSIZE.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.MAXITERATIONS !== undefined) {
|
if (options?.MAXITERATIONS !== undefined) {
|
||||||
args.push('MAXITERATIONS', options.MAXITERATIONS.toString());
|
parser.push('MAXITERATIONS', options.MAXITERATIONS.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.EXPANSION !== undefined) {
|
if (options?.EXPANSION !== undefined) {
|
||||||
args.push('EXPANSION', options.EXPANSION.toString());
|
parser.push('EXPANSION', options.EXPANSION.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import SCANDUMP from './SCANDUMP';
|
import SCANDUMP from './SCANDUMP';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('CF.SCANDUMP', () => {
|
describe('CF.SCANDUMP', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
SCANDUMP.transformArguments('key', 0),
|
parseArgs(SCANDUMP, 'key', 0),
|
||||||
['CF.SCANDUMP', 'key', '0']
|
['CF.SCANDUMP', 'key', '0']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
import { RedisArgument, TuplesReply, NumberReply, BlobStringReply, NullReply, UnwrapReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, TuplesReply, NumberReply, BlobStringReply, NullReply, UnwrapReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument, iterator: number) {
|
parseCommand(parser: CommandParser, key: RedisArgument, iterator: number) {
|
||||||
return ['CF.SCANDUMP', key, iterator.toString()];
|
parser.push('CF.SCANDUMP');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.push(iterator.toString());
|
||||||
},
|
},
|
||||||
transformReply(reply: UnwrapReply<TuplesReply<[NumberReply, BlobStringReply | NullReply]>>) {
|
transformReply(reply: UnwrapReply<TuplesReply<[NumberReply, BlobStringReply | NullReply]>>) {
|
||||||
return {
|
return {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import type { RedisCommands } from '@redis/client/dist/lib/RESP/types';
|
import type { RedisCommands } from '@redis/client/lib/RESP/types';
|
||||||
import ADD from './ADD';
|
import ADD from './ADD';
|
||||||
import ADDNX from './ADDNX';
|
import ADDNX from './ADDNX';
|
||||||
import COUNT from './COUNT';
|
import COUNT from './COUNT';
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import ADD from './ADD';
|
import ADD from './ADD';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TDIGEST.ADD', () => {
|
describe('TDIGEST.ADD', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
ADD.transformArguments('key', [1, 2]),
|
parseArgs(ADD, 'key', [1, 2]),
|
||||||
['TDIGEST.ADD', 'key', '1', '2']
|
['TDIGEST.ADD', 'key', '1', '2']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,16 +1,15 @@
|
|||||||
import { SimpleStringReply, Command, RedisArgument } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { SimpleStringReply, Command, RedisArgument } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(key: RedisArgument, values: Array<number>) {
|
parseCommand(parser: CommandParser, key: RedisArgument, values: Array<number>) {
|
||||||
const args = ['TDIGEST.ADD', key];
|
parser.push('TDIGEST.ADD');
|
||||||
|
parser.pushKey(key);
|
||||||
|
|
||||||
for (const value of values) {
|
for (const value of values) {
|
||||||
args.push(value.toString());
|
parser.push(value.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import BYRANK from './BYRANK';
|
import BYRANK from './BYRANK';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TDIGEST.BYRANK', () => {
|
describe('TDIGEST.BYRANK', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
BYRANK.transformArguments('key', [1, 2]),
|
parseArgs(BYRANK, 'key', [1, 2]),
|
||||||
['TDIGEST.BYRANK', 'key', '1', '2']
|
['TDIGEST.BYRANK', 'key', '1', '2']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,24 +1,25 @@
|
|||||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { transformDoubleArrayReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
import { transformDoubleArrayReply } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export function transformByRankArguments(
|
export function transformByRankArguments(
|
||||||
command: RedisArgument,
|
parser: CommandParser,
|
||||||
key: RedisArgument,
|
key: RedisArgument,
|
||||||
ranks: Array<number>
|
ranks: Array<number>
|
||||||
) {
|
) {
|
||||||
const args = [command, key];
|
parser.pushKey(key);
|
||||||
|
|
||||||
for (const rank of ranks) {
|
for (const rank of ranks) {
|
||||||
args.push(rank.toString());
|
parser.push(rank.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments: transformByRankArguments.bind(undefined, 'TDIGEST.BYRANK'),
|
parseCommand(...args: Parameters<typeof transformByRankArguments>) {
|
||||||
|
args[0].push('TDIGEST.BYRANK');
|
||||||
|
transformByRankArguments(...args);
|
||||||
|
},
|
||||||
transformReply: transformDoubleArrayReply
|
transformReply: transformDoubleArrayReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import BYREVRANK from './BYREVRANK';
|
import BYREVRANK from './BYREVRANK';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TDIGEST.BYREVRANK', () => {
|
describe('TDIGEST.BYREVRANK', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
BYREVRANK.transformArguments('key', [1, 2]),
|
parseArgs(BYREVRANK, 'key', [1, 2]),
|
||||||
['TDIGEST.BYREVRANK', 'key', '1', '2']
|
['TDIGEST.BYREVRANK', 'key', '1', '2']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
import { Command } from '@redis/client/dist/lib/RESP/types';
|
import { Command } from '@redis/client/lib/RESP/types';
|
||||||
import BYRANK, { transformByRankArguments } from './BYRANK';
|
import BYRANK, { transformByRankArguments } from './BYRANK';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: BYRANK.FIRST_KEY_INDEX,
|
|
||||||
IS_READ_ONLY: BYRANK.IS_READ_ONLY,
|
IS_READ_ONLY: BYRANK.IS_READ_ONLY,
|
||||||
transformArguments: transformByRankArguments.bind(undefined, 'TDIGEST.BYREVRANK'),
|
parseCommand(...args: Parameters<typeof transformByRankArguments>) {
|
||||||
|
args[0].push('TDIGEST.BYREVRANK');
|
||||||
|
transformByRankArguments(...args);
|
||||||
|
},
|
||||||
transformReply: BYRANK.transformReply
|
transformReply: BYRANK.transformReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import CDF from './CDF';
|
import CDF from './CDF';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TDIGEST.CDF', () => {
|
describe('TDIGEST.CDF', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
CDF.transformArguments('key', [1, 2]),
|
parseArgs(CDF, 'key', [1, 2]),
|
||||||
['TDIGEST.CDF', 'key', '1', '2']
|
['TDIGEST.CDF', 'key', '1', '2']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,17 +1,16 @@
|
|||||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { transformDoubleArrayReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
import { transformDoubleArrayReply } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument, values: Array<number>) {
|
parseCommand(parser: CommandParser, key: RedisArgument, values: Array<number>) {
|
||||||
const args = ['TDIGEST.CDF', key];
|
parser.push('TDIGEST.CDF');
|
||||||
|
parser.pushKey(key);
|
||||||
|
|
||||||
for (const item of values) {
|
for (const item of values) {
|
||||||
args.push(item.toString());
|
parser.push(item.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
|
||||||
},
|
},
|
||||||
transformReply: transformDoubleArrayReply
|
transformReply: transformDoubleArrayReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,19 +1,20 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import CREATE from './CREATE';
|
import CREATE from './CREATE';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TDIGEST.CREATE', () => {
|
describe('TDIGEST.CREATE', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('without options', () => {
|
it('without options', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
CREATE.transformArguments('key'),
|
parseArgs(CREATE, 'key'),
|
||||||
['TDIGEST.CREATE', 'key']
|
['TDIGEST.CREATE', 'key']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with COMPRESSION', () => {
|
it('with COMPRESSION', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
CREATE.transformArguments('key', {
|
parseArgs(CREATE, 'key', {
|
||||||
COMPRESSION: 100
|
COMPRESSION: 100
|
||||||
}),
|
}),
|
||||||
['TDIGEST.CREATE', 'key', 'COMPRESSION', '100']
|
['TDIGEST.CREATE', 'key', 'COMPRESSION', '100']
|
||||||
|
@@ -1,20 +1,19 @@
|
|||||||
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export interface TDigestCreateOptions {
|
export interface TDigestCreateOptions {
|
||||||
COMPRESSION?: number;
|
COMPRESSION?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(key: RedisArgument, options?: TDigestCreateOptions) {
|
parseCommand(parser: CommandParser, key: RedisArgument, options?: TDigestCreateOptions) {
|
||||||
const args = ['TDIGEST.CREATE', key];
|
parser.push('TDIGEST.CREATE');
|
||||||
|
parser.pushKey(key);
|
||||||
|
|
||||||
if (options?.COMPRESSION !== undefined) {
|
if (options?.COMPRESSION !== undefined) {
|
||||||
args.push('COMPRESSION', options.COMPRESSION.toString());
|
parser.push('COMPRESSION', options.COMPRESSION.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import INFO from './INFO';
|
import INFO from './INFO';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TDIGEST.INFO', () => {
|
describe('TDIGEST.INFO', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INFO.transformArguments('key'),
|
parseArgs(INFO, 'key'),
|
||||||
['TDIGEST.INFO', 'key']
|
['TDIGEST.INFO', 'key']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import { RedisArgument, Command, NumberReply, TuplesToMapReply, UnwrapReply, Resp2Reply, SimpleStringReply, TypeMapping } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, Command, NumberReply, TuplesToMapReply, UnwrapReply, Resp2Reply, SimpleStringReply, TypeMapping } from '@redis/client/lib/RESP/types';
|
||||||
import { transformInfoV2Reply } from '../bloom';
|
import { transformInfoV2Reply } from '../bloom';
|
||||||
|
|
||||||
export type TdInfoReplyMap = TuplesToMapReply<[
|
export type TdInfoReplyMap = TuplesToMapReply<[
|
||||||
@@ -14,10 +15,10 @@ export type TdInfoReplyMap = TuplesToMapReply<[
|
|||||||
]>;
|
]>;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||||
return ['TDIGEST.INFO', key];
|
parser.push('TDIGEST.INFO');
|
||||||
|
parser.pushKey(key);
|
||||||
},
|
},
|
||||||
transformReply: {
|
transformReply: {
|
||||||
2: (reply: UnwrapReply<Resp2Reply<TdInfoReplyMap>>, _, typeMapping?: TypeMapping): TdInfoReplyMap => {
|
2: (reply: UnwrapReply<Resp2Reply<TdInfoReplyMap>>, _, typeMapping?: TypeMapping): TdInfoReplyMap => {
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import MAX from './MAX';
|
import MAX from './MAX';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TDIGEST.MAX', () => {
|
describe('TDIGEST.MAX', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
MAX.transformArguments('key'),
|
parseArgs(MAX, 'key'),
|
||||||
['TDIGEST.MAX', 'key']
|
['TDIGEST.MAX', 'key']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { transformDoubleReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
import { transformDoubleReply } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||||
return ['TDIGEST.MAX', key];
|
parser.push('TDIGEST.MAX');
|
||||||
|
parser.pushKey(key);
|
||||||
},
|
},
|
||||||
transformReply: transformDoubleReply
|
transformReply: transformDoubleReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,20 +1,21 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import MERGE from './MERGE';
|
import MERGE from './MERGE';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TDIGEST.MERGE', () => {
|
describe('TDIGEST.MERGE', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
describe('source', () => {
|
describe('source', () => {
|
||||||
it('string', () => {
|
it('string', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
MERGE.transformArguments('destination', 'source'),
|
parseArgs(MERGE, 'destination', 'source'),
|
||||||
['TDIGEST.MERGE', 'destination', '1', 'source']
|
['TDIGEST.MERGE', 'destination', '1', 'source']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Array', () => {
|
it('Array', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
MERGE.transformArguments('destination', ['1', '2']),
|
parseArgs(MERGE, 'destination', ['1', '2']),
|
||||||
['TDIGEST.MERGE', 'destination', '2', '1', '2']
|
['TDIGEST.MERGE', 'destination', '2', '1', '2']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -22,7 +23,7 @@ describe('TDIGEST.MERGE', () => {
|
|||||||
|
|
||||||
it('with COMPRESSION', () => {
|
it('with COMPRESSION', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
MERGE.transformArguments('destination', 'source', {
|
parseArgs(MERGE, 'destination', 'source', {
|
||||||
COMPRESSION: 100
|
COMPRESSION: 100
|
||||||
}),
|
}),
|
||||||
['TDIGEST.MERGE', 'destination', '1', 'source', 'COMPRESSION', '100']
|
['TDIGEST.MERGE', 'destination', '1', 'source', 'COMPRESSION', '100']
|
||||||
@@ -31,7 +32,7 @@ describe('TDIGEST.MERGE', () => {
|
|||||||
|
|
||||||
it('with OVERRIDE', () => {
|
it('with OVERRIDE', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
MERGE.transformArguments('destination', 'source', {
|
parseArgs(MERGE, 'destination', 'source', {
|
||||||
OVERRIDE: true
|
OVERRIDE: true
|
||||||
}),
|
}),
|
||||||
['TDIGEST.MERGE', 'destination', '1', 'source', 'OVERRIDE']
|
['TDIGEST.MERGE', 'destination', '1', 'source', 'OVERRIDE']
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { RedisVariadicArgument, pushVariadicArgument } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
import { RedisVariadicArgument } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export interface TDigestMergeOptions {
|
export interface TDigestMergeOptions {
|
||||||
COMPRESSION?: number;
|
COMPRESSION?: number;
|
||||||
@@ -7,24 +8,24 @@ export interface TDigestMergeOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: undefined,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(
|
parseCommand(
|
||||||
|
parser: CommandParser,
|
||||||
destination: RedisArgument,
|
destination: RedisArgument,
|
||||||
source: RedisVariadicArgument,
|
source: RedisVariadicArgument,
|
||||||
options?: TDigestMergeOptions
|
options?: TDigestMergeOptions
|
||||||
) {
|
) {
|
||||||
const args = pushVariadicArgument(['TDIGEST.MERGE', destination], source);
|
parser.push('TDIGEST.MERGE');
|
||||||
|
parser.pushKey(destination);
|
||||||
|
parser.pushKeysLength(source);
|
||||||
|
|
||||||
if (options?.COMPRESSION !== undefined) {
|
if (options?.COMPRESSION !== undefined) {
|
||||||
args.push('COMPRESSION', options.COMPRESSION.toString());
|
parser.push('COMPRESSION', options.COMPRESSION.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.OVERRIDE) {
|
if (options?.OVERRIDE) {
|
||||||
args.push('OVERRIDE');
|
parser.push('OVERRIDE');
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import MIN from './MIN';
|
import MIN from './MIN';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TDIGEST.MIN', () => {
|
describe('TDIGEST.MIN', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
MIN.transformArguments('key'),
|
parseArgs(MIN, 'key'),
|
||||||
['TDIGEST.MIN', 'key']
|
['TDIGEST.MIN', 'key']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { transformDoubleReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
import { transformDoubleReply } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||||
return ['TDIGEST.MIN', key];
|
parser.push('TDIGEST.MIN');
|
||||||
|
parser.pushKey(key);
|
||||||
},
|
},
|
||||||
transformReply: transformDoubleReply
|
transformReply: transformDoubleReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import QUANTILE from './QUANTILE';
|
import QUANTILE from './QUANTILE';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TDIGEST.QUANTILE', () => {
|
describe('TDIGEST.QUANTILE', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
QUANTILE.transformArguments('key', [1, 2]),
|
parseArgs(QUANTILE, 'key', [1, 2]),
|
||||||
['TDIGEST.QUANTILE', 'key', '1', '2']
|
['TDIGEST.QUANTILE', 'key', '1', '2']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,17 +1,16 @@
|
|||||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { transformDoubleArrayReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
import { transformDoubleArrayReply } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument, quantiles: Array<number>) {
|
parseCommand(parser: CommandParser, key: RedisArgument, quantiles: Array<number>) {
|
||||||
const args = ['TDIGEST.QUANTILE', key];
|
parser.push('TDIGEST.QUANTILE');
|
||||||
|
parser.pushKey(key);
|
||||||
|
|
||||||
for (const quantile of quantiles) {
|
for (const quantile of quantiles) {
|
||||||
args.push(quantile.toString());
|
parser.push(quantile.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
|
||||||
},
|
},
|
||||||
transformReply: transformDoubleArrayReply
|
transformReply: transformDoubleArrayReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import RANK from './RANK';
|
import RANK from './RANK';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TDIGEST.RANK', () => {
|
describe('TDIGEST.RANK', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
RANK.transformArguments('key', [1, 2]),
|
parseArgs(RANK, 'key', [1, 2]),
|
||||||
['TDIGEST.RANK', 'key', '1', '2']
|
['TDIGEST.RANK', 'key', '1', '2']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,22 +1,23 @@
|
|||||||
import { RedisArgument, ArrayReply, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, ArrayReply, NumberReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export function transformRankArguments(
|
export function transformRankArguments(
|
||||||
command: RedisArgument,
|
parser: CommandParser,
|
||||||
key: RedisArgument,
|
key: RedisArgument,
|
||||||
values: Array<number>
|
values: Array<number>
|
||||||
) {
|
) {
|
||||||
const args = [command, key];
|
parser.pushKey(key);
|
||||||
|
|
||||||
for (const value of values) {
|
for (const value of values) {
|
||||||
args.push(value.toString());
|
parser.push(value.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments: transformRankArguments.bind(undefined, 'TDIGEST.RANK'),
|
parseCommand(...args: Parameters<typeof transformRankArguments>) {
|
||||||
|
args[0].push('TDIGEST.RANK');
|
||||||
|
transformRankArguments(...args);
|
||||||
|
},
|
||||||
transformReply: undefined as unknown as () => ArrayReply<NumberReply>
|
transformReply: undefined as unknown as () => ArrayReply<NumberReply>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import RESET from './RESET';
|
import RESET from './RESET';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TDIGEST.RESET', () => {
|
describe('TDIGEST.RESET', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
RESET.transformArguments('key'),
|
parseArgs(RESET, 'key'),
|
||||||
['TDIGEST.RESET', 'key']
|
['TDIGEST.RESET', 'key']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(key: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||||
return ['TDIGEST.RESET', key];
|
parser.push('TDIGEST.RESET');
|
||||||
|
parser.pushKey(key);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import REVRANK from './REVRANK';
|
import REVRANK from './REVRANK';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TDIGEST.REVRANK', () => {
|
describe('TDIGEST.REVRANK', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
REVRANK.transformArguments('key', [1, 2]),
|
parseArgs(REVRANK, 'key', [1, 2]),
|
||||||
['TDIGEST.REVRANK', 'key', '1', '2']
|
['TDIGEST.REVRANK', 'key', '1', '2']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
import { Command } from '@redis/client/dist/lib/RESP/types';
|
import { Command } from '@redis/client/lib/RESP/types';
|
||||||
import RANK, { transformRankArguments } from './RANK';
|
import RANK, { transformRankArguments } from './RANK';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: RANK.FIRST_KEY_INDEX,
|
|
||||||
IS_READ_ONLY: RANK.IS_READ_ONLY,
|
IS_READ_ONLY: RANK.IS_READ_ONLY,
|
||||||
transformArguments: transformRankArguments.bind(undefined, 'TDIGEST.REVRANK'),
|
parseCommand(...args: Parameters<typeof transformRankArguments>) {
|
||||||
|
args[0].push('TDIGEST.REVRANK');
|
||||||
|
transformRankArguments(...args);
|
||||||
|
},
|
||||||
transformReply: RANK.transformReply
|
transformReply: RANK.transformReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import TRIMMED_MEAN from './TRIMMED_MEAN';
|
import TRIMMED_MEAN from './TRIMMED_MEAN';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TDIGEST.TRIMMED_MEAN', () => {
|
describe('TDIGEST.TRIMMED_MEAN', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
TRIMMED_MEAN.transformArguments('key', 0, 1),
|
parseArgs(TRIMMED_MEAN, 'key', 0, 1),
|
||||||
['TDIGEST.TRIMMED_MEAN', 'key', '0', '1']
|
['TDIGEST.TRIMMED_MEAN', 'key', '0', '1']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,20 +1,18 @@
|
|||||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { transformDoubleReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
import { transformDoubleReply } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(
|
parseCommand(
|
||||||
|
parser: CommandParser,
|
||||||
key: RedisArgument,
|
key: RedisArgument,
|
||||||
lowCutPercentile: number,
|
lowCutPercentile: number,
|
||||||
highCutPercentile: number
|
highCutPercentile: number
|
||||||
) {
|
) {
|
||||||
return [
|
parser.push('TDIGEST.TRIMMED_MEAN');
|
||||||
'TDIGEST.TRIMMED_MEAN',
|
parser.pushKey(key);
|
||||||
key,
|
parser.push(lowCutPercentile.toString(), highCutPercentile.toString());
|
||||||
lowCutPercentile.toString(),
|
|
||||||
highCutPercentile.toString()
|
|
||||||
];
|
|
||||||
},
|
},
|
||||||
transformReply: transformDoubleReply
|
transformReply: transformDoubleReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import type { RedisCommands } from '@redis/client/dist/lib/RESP/types';
|
import type { RedisCommands } from '@redis/client/lib/RESP/types';
|
||||||
import ADD from './ADD';
|
import ADD from './ADD';
|
||||||
import BYRANK from './BYRANK';
|
import BYRANK from './BYRANK';
|
||||||
import BYREVRANK from './BYREVRANK';
|
import BYREVRANK from './BYREVRANK';
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import ADD from './ADD';
|
import ADD from './ADD';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TOPK.ADD', () => {
|
describe('TOPK.ADD', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
ADD.transformArguments('key', 'item'),
|
parseArgs(ADD, 'key', 'item'),
|
||||||
['TOPK.ADD', 'key', 'item']
|
['TOPK.ADD', 'key', 'item']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
import { RedisVariadicArgument } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(key: RedisArgument, items: RedisVariadicArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument, items: RedisVariadicArgument) {
|
||||||
return pushVariadicArguments(['TOPK.ADD', key], items);
|
parser.push('TOPK.ADD');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.pushVariadic(items);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
|
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import COUNT from './COUNT';
|
import COUNT from './COUNT';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TOPK.COUNT', () => {
|
describe('TOPK.COUNT', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
COUNT.transformArguments('key', 'item'),
|
parseArgs(COUNT, 'key', 'item'),
|
||||||
['TOPK.COUNT', 'key', 'item']
|
['TOPK.COUNT', 'key', 'item']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
import { RedisArgument, ArrayReply, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { RedisArgument, ArrayReply, NumberReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
import { RedisVariadicArgument } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument, items: RedisVariadicArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument, items: RedisVariadicArgument) {
|
||||||
return pushVariadicArguments(['TOPK.COUNT', key], items);
|
parser.push('TOPK.COUNT');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.pushVariadic(items);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => ArrayReply<NumberReply>
|
transformReply: undefined as unknown as () => ArrayReply<NumberReply>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,12 +1,13 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import INCRBY from './INCRBY';
|
import INCRBY from './INCRBY';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TOPK.INCRBY', () => {
|
describe('TOPK.INCRBY', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('single item', () => {
|
it('single item', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INCRBY.transformArguments('key', {
|
parseArgs(INCRBY, 'key', {
|
||||||
item: 'item',
|
item: 'item',
|
||||||
incrementBy: 1
|
incrementBy: 1
|
||||||
}),
|
}),
|
||||||
@@ -16,7 +17,7 @@ describe('TOPK.INCRBY', () => {
|
|||||||
|
|
||||||
it('multiple items', () => {
|
it('multiple items', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INCRBY.transformArguments('key', [{
|
parseArgs(INCRBY, 'key', [{
|
||||||
item: 'a',
|
item: 'a',
|
||||||
incrementBy: 1
|
incrementBy: 1
|
||||||
}, {
|
}, {
|
||||||
|
@@ -1,32 +1,32 @@
|
|||||||
import { RedisArgument, ArrayReply, SimpleStringReply, NullReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, ArrayReply, SimpleStringReply, NullReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export interface TopKIncrByItem {
|
export interface TopKIncrByItem {
|
||||||
item: string;
|
item: string;
|
||||||
incrementBy: number;
|
incrementBy: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function pushIncrByItem(args: Array<RedisArgument>, { item, incrementBy }: TopKIncrByItem) {
|
function pushIncrByItem(parser: CommandParser, { item, incrementBy }: TopKIncrByItem) {
|
||||||
args.push(item, incrementBy.toString());
|
parser.push(item, incrementBy.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: false,
|
IS_READ_ONLY: false,
|
||||||
transformArguments(
|
parseCommand(
|
||||||
|
parser: CommandParser,
|
||||||
key: RedisArgument,
|
key: RedisArgument,
|
||||||
items: TopKIncrByItem | Array<TopKIncrByItem>
|
items: TopKIncrByItem | Array<TopKIncrByItem>
|
||||||
) {
|
) {
|
||||||
const args = ['TOPK.INCRBY', key];
|
parser.push('TOPK.INCRBY');
|
||||||
|
parser.pushKey(key);
|
||||||
|
|
||||||
if (Array.isArray(items)) {
|
if (Array.isArray(items)) {
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
pushIncrByItem(args, item);
|
pushIncrByItem(parser, item);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pushIncrByItem(args, items);
|
pushIncrByItem(parser, items);
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => ArrayReply<SimpleStringReply | NullReply>
|
transformReply: undefined as unknown as () => ArrayReply<SimpleStringReply | NullReply>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import INFO from './INFO';
|
import INFO from './INFO';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TOPK INFO', () => {
|
describe('TOPK INFO', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
INFO.transformArguments('key'),
|
parseArgs(INFO, 'key'),
|
||||||
['TOPK.INFO', 'key']
|
['TOPK.INFO', 'key']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { transformDoubleReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
import { RedisArgument, TuplesToMapReply, NumberReply, DoubleReply, UnwrapReply, Resp2Reply, Command, SimpleStringReply, TypeMapping } from '@redis/client/dist/lib/RESP/types';
|
import { RedisArgument, TuplesToMapReply, NumberReply, DoubleReply, UnwrapReply, Resp2Reply, Command, SimpleStringReply, TypeMapping } from '@redis/client/lib/RESP/types';
|
||||||
|
import { transformDoubleReply } from '@redis/client/lib/commands/generic-transformers';
|
||||||
import { transformInfoV2Reply } from '../bloom';
|
import { transformInfoV2Reply } from '../bloom';
|
||||||
|
|
||||||
export type TopKInfoReplyMap = TuplesToMapReply<[
|
export type TopKInfoReplyMap = TuplesToMapReply<[
|
||||||
@@ -10,10 +11,10 @@ export type TopKInfoReplyMap = TuplesToMapReply<[
|
|||||||
]>;
|
]>;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||||
return ['TOPK.INFO', key];
|
parser.push('TOPK.INFO');
|
||||||
|
parser.pushKey(key);
|
||||||
},
|
},
|
||||||
transformReply: {
|
transformReply: {
|
||||||
2: (reply: UnwrapReply<Resp2Reply<TopKInfoReplyMap>>, preserve?: any, typeMapping?: TypeMapping): TopKInfoReplyMap => {
|
2: (reply: UnwrapReply<Resp2Reply<TopKInfoReplyMap>>, preserve?: any, typeMapping?: TypeMapping): TopKInfoReplyMap => {
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import LIST from './LIST';
|
import LIST from './LIST';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TOPK.LIST', () => {
|
describe('TOPK.LIST', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
LIST.transformArguments('key'),
|
parseArgs(LIST, 'key'),
|
||||||
['TOPK.LIST', 'key']
|
['TOPK.LIST', 'key']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||||
return ['TOPK.LIST', key];
|
parser.push('TOPK.LIST');
|
||||||
|
parser.pushKey(key);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
|
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,13 +1,14 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import LIST_WITHCOUNT from './LIST_WITHCOUNT';
|
import LIST_WITHCOUNT from './LIST_WITHCOUNT';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TOPK.LIST WITHCOUNT', () => {
|
describe('TOPK.LIST WITHCOUNT', () => {
|
||||||
testUtils.isVersionGreaterThanHook([2, 2, 9]);
|
testUtils.isVersionGreaterThanHook([2, 2, 9]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
LIST_WITHCOUNT.transformArguments('key'),
|
parseArgs(LIST_WITHCOUNT, 'key'),
|
||||||
['TOPK.LIST', 'key', 'WITHCOUNT']
|
['TOPK.LIST', 'key', 'WITHCOUNT']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
import { RedisArgument, ArrayReply, BlobStringReply, NumberReply, UnwrapReply, Command } from '@redis/client/dist/lib/RESP/types';
|
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||||
|
import { RedisArgument, ArrayReply, BlobStringReply, NumberReply, UnwrapReply, Command } from '@redis/client/lib/RESP/types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument) {
|
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||||
return ['TOPK.LIST', key, 'WITHCOUNT'];
|
parser.push('TOPK.LIST');
|
||||||
|
parser.pushKey(key);
|
||||||
|
parser.push('WITHCOUNT');
|
||||||
},
|
},
|
||||||
transformReply(rawReply: UnwrapReply<ArrayReply<BlobStringReply | NumberReply>>) {
|
transformReply(rawReply: UnwrapReply<ArrayReply<BlobStringReply | NumberReply>>) {
|
||||||
const reply: Array<{
|
const reply: Array<{
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert } from 'node:assert';
|
import { strict as assert } from 'node:assert';
|
||||||
import testUtils, { GLOBAL } from '../../test-utils';
|
import testUtils, { GLOBAL } from '../../test-utils';
|
||||||
import QUERY from './QUERY';
|
import QUERY from './QUERY';
|
||||||
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||||
|
|
||||||
describe('TOPK.QUERY', () => {
|
describe('TOPK.QUERY', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
QUERY.transformArguments('key', 'item'),
|
parseArgs(QUERY, 'key', 'item'),
|
||||||
['TOPK.QUERY', 'key', 'item']
|
['TOPK.QUERY', 'key', 'item']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user