You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +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:
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import ADD from './ADD';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('BF.ADD', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
ADD.transformArguments('key', 'item'),
|
||||
parseArgs(ADD, 'key', 'item'),
|
||||
['BF.ADD', 'key', 'item']
|
||||
);
|
||||
});
|
||||
|
@@ -1,11 +1,13 @@
|
||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||
import { transformBooleanReply } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, item: RedisArgument) {
|
||||
return ['BF.ADD', key, item];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, item: RedisArgument) {
|
||||
parser.push('BF.ADD');
|
||||
parser.pushKey(key);
|
||||
parser.push(item);
|
||||
},
|
||||
transformReply: transformBooleanReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import CARD from './CARD';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('BF.CARD', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
CARD.transformArguments('bloom'),
|
||||
parseArgs(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 {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument) {
|
||||
return ['BF.CARD', key];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||
parser.push('BF.CARD');
|
||||
parser.pushKey(key);
|
||||
},
|
||||
transformReply: undefined as unknown as () => NumberReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import EXISTS from './EXISTS';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('BF.EXISTS', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
EXISTS.transformArguments('key', 'item'),
|
||||
parseArgs(EXISTS, 'key', 'item'),
|
||||
['BF.EXISTS', 'key', 'item']
|
||||
);
|
||||
});
|
||||
|
@@ -1,11 +1,13 @@
|
||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||
import { transformBooleanReply } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument, item: RedisArgument) {
|
||||
return ['BF.EXISTS', key, item];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, item: RedisArgument) {
|
||||
parser.push('BF.EXISTS');
|
||||
parser.pushKey(key);
|
||||
parser.push(item);
|
||||
},
|
||||
transformReply: transformBooleanReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import INFO from './INFO';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('BF.INFO', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
INFO.transformArguments('bloom'),
|
||||
parseArgs(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 '.';
|
||||
|
||||
export type BfInfoReplyMap = TuplesToMapReply<[
|
||||
@@ -9,19 +10,11 @@ export type BfInfoReplyMap = TuplesToMapReply<[
|
||||
[SimpleStringReply<'Expansion rate'>, NullReply | NumberReply]
|
||||
]>;
|
||||
|
||||
export interface BfInfoReply {
|
||||
capacity: NumberReply;
|
||||
size: NumberReply;
|
||||
numberOfFilters: NumberReply;
|
||||
numberOfInsertedItems: NumberReply;
|
||||
expansionRate: NullReply | NumberReply;
|
||||
}
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument) {
|
||||
return ['BF.INFO', key];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||
parser.push('BF.INFO');
|
||||
parser.pushKey(key);
|
||||
},
|
||||
transformReply: {
|
||||
2: (reply: UnwrapReply<Resp2Reply<BfInfoReplyMap>>, _, typeMapping?: TypeMapping): BfInfoReplyMap => {
|
||||
|
@@ -1,54 +1,55 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import INSERT from './INSERT';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('BF.INSERT', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
INSERT.transformArguments('key', 'item'),
|
||||
parseArgs(INSERT, 'key', 'item'),
|
||||
['BF.INSERT', 'key', 'ITEMS', 'item']
|
||||
);
|
||||
});
|
||||
|
||||
it('with CAPACITY', () => {
|
||||
assert.deepEqual(
|
||||
INSERT.transformArguments('key', 'item', { CAPACITY: 100 }),
|
||||
parseArgs(INSERT, 'key', 'item', { CAPACITY: 100 }),
|
||||
['BF.INSERT', 'key', 'CAPACITY', '100', 'ITEMS', 'item']
|
||||
);
|
||||
});
|
||||
|
||||
it('with ERROR', () => {
|
||||
assert.deepEqual(
|
||||
INSERT.transformArguments('key', 'item', { ERROR: 0.01 }),
|
||||
parseArgs(INSERT, 'key', 'item', { ERROR: 0.01 }),
|
||||
['BF.INSERT', 'key', 'ERROR', '0.01', 'ITEMS', 'item']
|
||||
);
|
||||
});
|
||||
|
||||
it('with EXPANSION', () => {
|
||||
assert.deepEqual(
|
||||
INSERT.transformArguments('key', 'item', { EXPANSION: 1 }),
|
||||
parseArgs(INSERT, 'key', 'item', { EXPANSION: 1 }),
|
||||
['BF.INSERT', 'key', 'EXPANSION', '1', 'ITEMS', 'item']
|
||||
);
|
||||
});
|
||||
|
||||
it('with NOCREATE', () => {
|
||||
assert.deepEqual(
|
||||
INSERT.transformArguments('key', 'item', { NOCREATE: true }),
|
||||
parseArgs(INSERT, 'key', 'item', { NOCREATE: true }),
|
||||
['BF.INSERT', 'key', 'NOCREATE', 'ITEMS', 'item']
|
||||
);
|
||||
});
|
||||
|
||||
it('with NONSCALING', () => {
|
||||
assert.deepEqual(
|
||||
INSERT.transformArguments('key', 'item', { NONSCALING: true }),
|
||||
parseArgs(INSERT, 'key', 'item', { NONSCALING: true }),
|
||||
['BF.INSERT', 'key', 'NONSCALING', 'ITEMS', 'item']
|
||||
);
|
||||
});
|
||||
|
||||
it('with CAPACITY, ERROR, EXPANSION, NOCREATE and NONSCALING', () => {
|
||||
assert.deepEqual(
|
||||
INSERT.transformArguments('key', 'item', {
|
||||
parseArgs(INSERT, 'key', 'item', {
|
||||
CAPACITY: 100,
|
||||
ERROR: 0.01,
|
||||
EXPANSION: 1,
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||
import { RedisVariadicArgument } from '@redis/client/lib/commands/generic-transformers';
|
||||
import { transformBooleanArrayReply } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export interface BfInsertOptions {
|
||||
CAPACITY?: number;
|
||||
@@ -11,37 +12,38 @@ export interface BfInsertOptions {
|
||||
}
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(
|
||||
parseCommand(
|
||||
parser: CommandParser,
|
||||
key: RedisArgument,
|
||||
items: RedisVariadicArgument,
|
||||
options?: BfInsertOptions
|
||||
) {
|
||||
const args = ['BF.INSERT', key];
|
||||
parser.push('BF.INSERT');
|
||||
parser.pushKey(key);
|
||||
|
||||
if (options?.CAPACITY !== undefined) {
|
||||
args.push('CAPACITY', options.CAPACITY.toString());
|
||||
parser.push('CAPACITY', options.CAPACITY.toString());
|
||||
}
|
||||
|
||||
if (options?.ERROR !== undefined) {
|
||||
args.push('ERROR', options.ERROR.toString());
|
||||
parser.push('ERROR', options.ERROR.toString());
|
||||
}
|
||||
|
||||
if (options?.EXPANSION !== undefined) {
|
||||
args.push('EXPANSION', options.EXPANSION.toString());
|
||||
parser.push('EXPANSION', options.EXPANSION.toString());
|
||||
}
|
||||
|
||||
if (options?.NOCREATE) {
|
||||
args.push('NOCREATE');
|
||||
parser.push('NOCREATE');
|
||||
}
|
||||
|
||||
if (options?.NONSCALING) {
|
||||
args.push('NONSCALING');
|
||||
parser.push('NONSCALING');
|
||||
}
|
||||
|
||||
args.push('ITEMS');
|
||||
return pushVariadicArguments(args, items);
|
||||
parser.push('ITEMS');
|
||||
parser.pushVariadic(items);
|
||||
},
|
||||
transformReply: transformBooleanArrayReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -2,11 +2,12 @@ import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import LOADCHUNK from './LOADCHUNK';
|
||||
import { RESP_TYPES } from '@redis/client';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('BF.LOADCHUNK', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
LOADCHUNK.transformArguments('key', 0, ''),
|
||||
parseArgs(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 {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, iterator: number, chunk: RedisArgument) {
|
||||
return ['BF.LOADCHUNK', key, iterator.toString(), chunk];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, iterator: number, chunk: RedisArgument) {
|
||||
parser.push('BF.LOADCHUNK');
|
||||
parser.pushKey(key);
|
||||
parser.push(iterator.toString(), chunk);
|
||||
},
|
||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import MADD from './MADD';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('BF.MADD', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
MADD.transformArguments('key', ['1', '2']),
|
||||
parseArgs(MADD, 'key', ['1', '2']),
|
||||
['BF.MADD', 'key', '1', '2']
|
||||
);
|
||||
});
|
||||
|
@@ -1,12 +1,14 @@
|
||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||
import { RedisVariadicArgument } from '@redis/client/lib/commands/generic-transformers';
|
||||
import { transformBooleanArrayReply } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, items: RedisVariadicArgument) {
|
||||
return pushVariadicArguments(['BF.MADD', key], items);
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, items: RedisVariadicArgument) {
|
||||
parser.push('BF.MADD');
|
||||
parser.pushKey(key);
|
||||
parser.pushVariadic(items);
|
||||
},
|
||||
transformReply: transformBooleanArrayReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import MEXISTS from './MEXISTS';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('BF.MEXISTS', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
MEXISTS.transformArguments('key', ['1', '2']),
|
||||
parseArgs(MEXISTS, 'key', ['1', '2']),
|
||||
['BF.MEXISTS', 'key', '1', '2']
|
||||
);
|
||||
});
|
||||
|
@@ -1,12 +1,14 @@
|
||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||
import { RedisVariadicArgument } from '@redis/client/lib/commands/generic-transformers';
|
||||
import { transformBooleanArrayReply } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument, items: RedisVariadicArgument) {
|
||||
return pushVariadicArguments(['BF.MEXISTS', key], items);
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, items: RedisVariadicArgument) {
|
||||
parser.push('BF.MEXISTS');
|
||||
parser.pushKey(key);
|
||||
parser.pushVariadic(items);
|
||||
},
|
||||
transformReply: transformBooleanArrayReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,19 +1,20 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import RESERVE from './RESERVE';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('BF.RESERVE', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
RESERVE.transformArguments('key', 0.01, 100),
|
||||
parseArgs(RESERVE, 'key', 0.01, 100),
|
||||
['BF.RESERVE', 'key', '0.01', '100']
|
||||
);
|
||||
});
|
||||
|
||||
it('with EXPANSION', () => {
|
||||
assert.deepEqual(
|
||||
RESERVE.transformArguments('key', 0.01, 100, {
|
||||
parseArgs(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', () => {
|
||||
assert.deepEqual(
|
||||
RESERVE.transformArguments('key', 0.01, 100, {
|
||||
parseArgs(RESERVE, 'key', 0.01, 100, {
|
||||
NONSCALING: true
|
||||
}),
|
||||
['BF.RESERVE', 'key', '0.01', '100', 'NONSCALING']
|
||||
@@ -31,7 +32,7 @@ describe('BF.RESERVE', () => {
|
||||
|
||||
it('with EXPANSION and NONSCALING', () => {
|
||||
assert.deepEqual(
|
||||
RESERVE.transformArguments('key', 0.01, 100, {
|
||||
parseArgs(RESERVE, 'key', 0.01, 100, {
|
||||
EXPANSION: 1,
|
||||
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 {
|
||||
EXPANSION?: number;
|
||||
@@ -6,25 +7,25 @@ export interface BfReserveOptions {
|
||||
}
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(
|
||||
parseCommand(
|
||||
parser: CommandParser,
|
||||
key: RedisArgument,
|
||||
errorRate: number,
|
||||
capacity: number,
|
||||
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) {
|
||||
args.push('EXPANSION', options.EXPANSION.toString());
|
||||
parser.push('EXPANSION', options.EXPANSION.toString());
|
||||
}
|
||||
|
||||
if (options?.NONSCALING) {
|
||||
args.push('NONSCALING');
|
||||
parser.push('NONSCALING');
|
||||
}
|
||||
|
||||
return args;
|
||||
},
|
||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import SCANDUMP from './SCANDUMP';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('BF.SCANDUMP', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
SCANDUMP.transformArguments('key', 0),
|
||||
parseArgs(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 {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument, iterator: number) {
|
||||
return ['BF.SCANDUMP', key, iterator.toString()];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, iterator: number) {
|
||||
parser.push('BF.SCANDUMP');
|
||||
parser.pushKey(key);
|
||||
parser.push(iterator.toString());
|
||||
},
|
||||
transformReply(reply: UnwrapReply<TuplesReply<[NumberReply, BlobStringReply]>>) {
|
||||
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 CARD from './CARD';
|
||||
|
@@ -1,12 +1,13 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import INCRBY from './INCRBY';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('CMS.INCRBY', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('single item', () => {
|
||||
assert.deepEqual(
|
||||
INCRBY.transformArguments('key', {
|
||||
parseArgs(INCRBY, 'key', {
|
||||
item: 'item',
|
||||
incrementBy: 1
|
||||
}),
|
||||
@@ -16,7 +17,7 @@ describe('CMS.INCRBY', () => {
|
||||
|
||||
it('multiple items', () => {
|
||||
assert.deepEqual(
|
||||
INCRBY.transformArguments('key', [{
|
||||
parseArgs(INCRBY, 'key', [{
|
||||
item: 'a',
|
||||
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 {
|
||||
item: RedisArgument;
|
||||
@@ -6,27 +7,26 @@ export interface BfIncrByItem {
|
||||
}
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(
|
||||
parseCommand(
|
||||
parser: CommandParser,
|
||||
key: RedisArgument,
|
||||
items: BfIncrByItem | Array<BfIncrByItem>
|
||||
) {
|
||||
const args = ['CMS.INCRBY', key];
|
||||
parser.push('CMS.INCRBY');
|
||||
parser.pushKey(key);
|
||||
|
||||
if (Array.isArray(items)) {
|
||||
for (const item of items) {
|
||||
pushIncrByItem(args, item);
|
||||
pushIncrByItem(parser, item);
|
||||
}
|
||||
} else {
|
||||
pushIncrByItem(args, items);
|
||||
pushIncrByItem(parser, items);
|
||||
}
|
||||
|
||||
return args;
|
||||
},
|
||||
transformReply: undefined as unknown as () => ArrayReply<NumberReply>
|
||||
} as const satisfies Command;
|
||||
|
||||
function pushIncrByItem(args: Array<RedisArgument>, { item, incrementBy }: BfIncrByItem): void {
|
||||
args.push(item, incrementBy.toString());
|
||||
function pushIncrByItem(parser: CommandParser, { item, incrementBy }: BfIncrByItem): void {
|
||||
parser.push(item, incrementBy.toString());
|
||||
}
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import INFO from './INFO';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('CMS.INFO', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
INFO.transformArguments('key'),
|
||||
parseArgs(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';
|
||||
|
||||
export type CmsInfoReplyMap = TuplesToMapReply<[
|
||||
@@ -14,10 +15,10 @@ export interface CmsInfoReply {
|
||||
}
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument) {
|
||||
return ['CMS.INFO', key];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||
parser.push('CMS.INFO');
|
||||
parser.pushKey(key);
|
||||
},
|
||||
transformReply: {
|
||||
2: (reply: UnwrapReply<Resp2Reply<CmsInfoReplyMap>>, _, typeMapping?: TypeMapping): CmsInfoReply => {
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import INITBYDIM from './INITBYDIM';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('CMS.INITBYDIM', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
INITBYDIM.transformArguments('key', 1000, 5),
|
||||
parseArgs(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 {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, width: number, depth: number) {
|
||||
return ['CMS.INITBYDIM', key, width.toString(), depth.toString()];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, width: number, depth: number) {
|
||||
parser.push('CMS.INITBYDIM');
|
||||
parser.pushKey(key);
|
||||
parser.push(width.toString(), depth.toString());
|
||||
},
|
||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import INITBYPROB from './INITBYPROB';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('CMS.INITBYPROB', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
INITBYPROB.transformArguments('key', 0.001, 0.01),
|
||||
parseArgs(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 {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, error: number, probability: number) {
|
||||
return ['CMS.INITBYPROB', key, error.toString(), probability.toString()];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, error: number, probability: number) {
|
||||
parser.push('CMS.INITBYPROB');
|
||||
parser.pushKey(key);
|
||||
parser.push(error.toString(), probability.toString());
|
||||
},
|
||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,19 +1,20 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import MERGE from './MERGE';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('CMS.MERGE', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('without WEIGHTS', () => {
|
||||
assert.deepEqual(
|
||||
MERGE.transformArguments('destination', ['source']),
|
||||
parseArgs(MERGE, 'destination', ['source']),
|
||||
['CMS.MERGE', 'destination', '1', 'source']
|
||||
);
|
||||
});
|
||||
|
||||
it('with WEIGHTS', () => {
|
||||
assert.deepEqual(
|
||||
MERGE.transformArguments('destination', [{
|
||||
parseArgs(MERGE, 'destination', [{
|
||||
name: 'source',
|
||||
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 {
|
||||
name: RedisArgument;
|
||||
@@ -8,26 +9,27 @@ interface BfMergeSketch {
|
||||
export type BfMergeSketches = Array<RedisArgument> | Array<BfMergeSketch>;
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(
|
||||
parseCommand(
|
||||
parser: CommandParser,
|
||||
destination: RedisArgument,
|
||||
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)) {
|
||||
args = args.concat(source);
|
||||
parser.pushVariadic(source);
|
||||
} else {
|
||||
const { length } = args;
|
||||
args[length + source.length] = 'WEIGHTS';
|
||||
for (let i = 0; i < source.length; i++) {
|
||||
args[length + i] = source[i].name;
|
||||
args[length + source.length + i + 1] = source[i].weight.toString();
|
||||
parser.push(source[i].name);
|
||||
}
|
||||
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'>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import QUERY from './QUERY';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('CMS.QUERY', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
QUERY.transformArguments('key', 'item'),
|
||||
parseArgs(QUERY, 'key', 'item'),
|
||||
['CMS.QUERY', 'key', 'item']
|
||||
);
|
||||
});
|
||||
|
@@ -1,11 +1,13 @@
|
||||
import { ArrayReply, NumberReply, Command, RedisArgument } from '@redis/client/dist/lib/RESP/types';
|
||||
import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { ArrayReply, NumberReply, Command, RedisArgument } from '@redis/client/lib/RESP/types';
|
||||
import { RedisVariadicArgument } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument, items: RedisVariadicArgument) {
|
||||
return pushVariadicArguments(['CMS.QUERY', key], items);
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, items: RedisVariadicArgument) {
|
||||
parser.push('CMS.QUERY');
|
||||
parser.pushKey(key);
|
||||
parser.pushVariadic(items);
|
||||
},
|
||||
transformReply: undefined as unknown as () => ArrayReply<NumberReply>
|
||||
} 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 INFO from './INFO';
|
||||
import INITBYDIM from './INITBYDIM';
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import ADD from './ADD';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('CF.ADD', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
ADD.transformArguments('key', 'item'),
|
||||
parseArgs(ADD, 'key', 'item'),
|
||||
['CF.ADD', 'key', 'item']
|
||||
);
|
||||
});
|
||||
|
@@ -1,11 +1,13 @@
|
||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||
import { transformBooleanReply } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, item: RedisArgument) {
|
||||
return ['CF.ADD', key, item];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, item: RedisArgument) {
|
||||
parser.push('CF.ADD');
|
||||
parser.pushKey(key);
|
||||
parser.push(item);
|
||||
},
|
||||
transformReply: transformBooleanReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import ADDNX from './ADDNX';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('CF.ADDNX', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
ADDNX.transformArguments('key', 'item'),
|
||||
parseArgs(ADDNX, 'key', 'item'),
|
||||
['CF.ADDNX', 'key', 'item']
|
||||
);
|
||||
});
|
||||
|
@@ -1,11 +1,13 @@
|
||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||
import { transformBooleanReply } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, item: RedisArgument) {
|
||||
return ['CF.ADDNX', key, item];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, item: RedisArgument) {
|
||||
parser.push('CF.ADDNX');
|
||||
parser.pushKey(key);
|
||||
parser.push(item);
|
||||
},
|
||||
transformReply: transformBooleanReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import COUNT from './COUNT';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('CF.COUNT', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
COUNT.transformArguments('key', 'item'),
|
||||
parseArgs(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 {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument, item: RedisArgument) {
|
||||
return ['CF.COUNT', key, item];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, item: RedisArgument) {
|
||||
parser.push('CF.COUNT');
|
||||
parser.pushKey(key);
|
||||
parser.push(item);
|
||||
},
|
||||
transformReply: undefined as unknown as () => NumberReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import DEL from './DEL';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('CF.DEL', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
DEL.transformArguments('key', 'item'),
|
||||
parseArgs(DEL, 'key', 'item'),
|
||||
['CF.DEL', 'key', 'item']
|
||||
);
|
||||
});
|
||||
|
@@ -1,11 +1,13 @@
|
||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||
import { transformBooleanReply } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, item: RedisArgument) {
|
||||
return ['CF.DEL', key, item];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, item: RedisArgument) {
|
||||
parser.push('CF.DEL');
|
||||
parser.pushKey(key);
|
||||
parser.push(item);
|
||||
},
|
||||
transformReply: transformBooleanReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import EXISTS from './EXISTS';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('CF.EXISTS', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
EXISTS.transformArguments('key', 'item'),
|
||||
parseArgs(EXISTS, 'key', 'item'),
|
||||
['CF.EXISTS', 'key', 'item']
|
||||
);
|
||||
});
|
||||
|
@@ -1,11 +1,13 @@
|
||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { transformBooleanReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||
import { transformBooleanReply } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, item: RedisArgument) {
|
||||
return ['CF.EXISTS', key, item];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, item: RedisArgument) {
|
||||
parser.push('CF.EXISTS');
|
||||
parser.pushKey(key);
|
||||
parser.push(item);
|
||||
},
|
||||
transformReply: transformBooleanReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import INFO from './INFO';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('CF.INFO', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
INFO.transformArguments('cuckoo'),
|
||||
parseArgs(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';
|
||||
|
||||
export type CfInfoReplyMap = TuplesToMapReply<[
|
||||
@@ -13,10 +14,10 @@ export type CfInfoReplyMap = TuplesToMapReply<[
|
||||
]>;
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument) {
|
||||
return ['CF.INFO', key];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||
parser.push('CF.INFO');
|
||||
parser.pushKey(key);
|
||||
},
|
||||
transformReply: {
|
||||
2: (reply: UnwrapReply<Resp2Reply<CfInfoReplyMap>>, _, typeMapping?: TypeMapping): CfInfoReplyMap => {
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import INSERT from './INSERT';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('CF.INSERT', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
INSERT.transformArguments('key', 'item', {
|
||||
parseArgs(INSERT, 'key', 'item', {
|
||||
CAPACITY: 100,
|
||||
NOCREATE: true
|
||||
}),
|
||||
|
@@ -1,34 +1,37 @@
|
||||
import { Command, RedisArgument } from '@redis/client/dist/lib/RESP/types';
|
||||
import { RedisVariadicArgument, pushVariadicArguments, transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { Command, RedisArgument } from '@redis/client/lib/RESP/types';
|
||||
import { RedisVariadicArgument, transformBooleanArrayReply } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export interface CfInsertOptions {
|
||||
CAPACITY?: number;
|
||||
NOCREATE?: boolean;
|
||||
}
|
||||
|
||||
export function transofrmCfInsertArguments(
|
||||
command: RedisArgument,
|
||||
export function parseCfInsertArguments(
|
||||
parser: CommandParser,
|
||||
key: RedisArgument,
|
||||
items: RedisVariadicArgument,
|
||||
options?: CfInsertOptions
|
||||
) {
|
||||
const args = [command, key];
|
||||
parser.pushKey(key);
|
||||
|
||||
if (options?.CAPACITY !== undefined) {
|
||||
args.push('CAPACITY', options.CAPACITY.toString());
|
||||
parser.push('CAPACITY', options.CAPACITY.toString());
|
||||
}
|
||||
|
||||
if (options?.NOCREATE) {
|
||||
args.push('NOCREATE');
|
||||
parser.push('NOCREATE');
|
||||
}
|
||||
|
||||
args.push('ITEMS');
|
||||
return pushVariadicArguments(args, items);
|
||||
parser.push('ITEMS');
|
||||
parser.pushVariadic(items);
|
||||
}
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments: transofrmCfInsertArguments.bind(undefined, 'CF.INSERT'),
|
||||
parseCommand(...args: Parameters<typeof parseCfInsertArguments>) {
|
||||
args[0].push('CF.INSERT');
|
||||
parseCfInsertArguments(...args);
|
||||
},
|
||||
transformReply: transformBooleanArrayReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import INSERTNX from './INSERTNX';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('CF.INSERTNX', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
INSERTNX.transformArguments('key', 'item', {
|
||||
parseArgs(INSERTNX, 'key', 'item', {
|
||||
CAPACITY: 100,
|
||||
NOCREATE: true
|
||||
}),
|
||||
|
@@ -1,9 +1,11 @@
|
||||
import { Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import INSERT, { transofrmCfInsertArguments } from './INSERT';
|
||||
import { Command } from '@redis/client/lib/RESP/types';
|
||||
import INSERT, { parseCfInsertArguments } from './INSERT';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: INSERT.FIRST_KEY_INDEX,
|
||||
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
|
||||
} as const satisfies Command;
|
||||
|
@@ -2,11 +2,12 @@ import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import LOADCHUNK from './LOADCHUNK';
|
||||
import { RESP_TYPES } from '@redis/client';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('CF.LOADCHUNK', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
LOADCHUNK.transformArguments('item', 0, ''),
|
||||
parseArgs(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 {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, iterator: number, chunk: RedisArgument) {
|
||||
return ['CF.LOADCHUNK', key, iterator.toString(), chunk];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, iterator: number, chunk: RedisArgument) {
|
||||
parser.push('CF.LOADCHUNK');
|
||||
parser.pushKey(key);
|
||||
parser.push(iterator.toString(), chunk);
|
||||
},
|
||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,19 +1,20 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import RESERVE from './RESERVE';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('CF.RESERVE', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
RESERVE.transformArguments('key', 4),
|
||||
parseArgs(RESERVE, 'key', 4),
|
||||
['CF.RESERVE', 'key', '4']
|
||||
);
|
||||
});
|
||||
|
||||
it('with EXPANSION', () => {
|
||||
assert.deepEqual(
|
||||
RESERVE.transformArguments('key', 4, {
|
||||
parseArgs(RESERVE, 'key', 4, {
|
||||
EXPANSION: 1
|
||||
}),
|
||||
['CF.RESERVE', 'key', '4', 'EXPANSION', '1']
|
||||
@@ -22,7 +23,7 @@ describe('CF.RESERVE', () => {
|
||||
|
||||
it('with BUCKETSIZE', () => {
|
||||
assert.deepEqual(
|
||||
RESERVE.transformArguments('key', 4, {
|
||||
parseArgs(RESERVE, 'key', 4, {
|
||||
BUCKETSIZE: 2
|
||||
}),
|
||||
['CF.RESERVE', 'key', '4', 'BUCKETSIZE', '2']
|
||||
@@ -31,7 +32,7 @@ describe('CF.RESERVE', () => {
|
||||
|
||||
it('with MAXITERATIONS', () => {
|
||||
assert.deepEqual(
|
||||
RESERVE.transformArguments('key', 4, {
|
||||
parseArgs(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 {
|
||||
BUCKETSIZE?: number;
|
||||
@@ -7,28 +8,28 @@ export interface CfReserveOptions {
|
||||
}
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(
|
||||
parseCommand(
|
||||
parser: CommandParser,
|
||||
key: RedisArgument,
|
||||
capacity: number,
|
||||
options?: CfReserveOptions
|
||||
) {
|
||||
const args = ['CF.RESERVE', key, capacity.toString()];
|
||||
parser.push('CF.RESERVE');
|
||||
parser.pushKey(key);
|
||||
parser.push(capacity.toString());
|
||||
|
||||
if (options?.BUCKETSIZE !== undefined) {
|
||||
args.push('BUCKETSIZE', options.BUCKETSIZE.toString());
|
||||
parser.push('BUCKETSIZE', options.BUCKETSIZE.toString());
|
||||
}
|
||||
|
||||
if (options?.MAXITERATIONS !== undefined) {
|
||||
args.push('MAXITERATIONS', options.MAXITERATIONS.toString());
|
||||
parser.push('MAXITERATIONS', options.MAXITERATIONS.toString());
|
||||
}
|
||||
|
||||
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'>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import SCANDUMP from './SCANDUMP';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('CF.SCANDUMP', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
SCANDUMP.transformArguments('key', 0),
|
||||
parseArgs(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 {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument, iterator: number) {
|
||||
return ['CF.SCANDUMP', key, iterator.toString()];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, iterator: number) {
|
||||
parser.push('CF.SCANDUMP');
|
||||
parser.pushKey(key);
|
||||
parser.push(iterator.toString());
|
||||
},
|
||||
transformReply(reply: UnwrapReply<TuplesReply<[NumberReply, BlobStringReply | NullReply]>>) {
|
||||
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 ADDNX from './ADDNX';
|
||||
import COUNT from './COUNT';
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import ADD from './ADD';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TDIGEST.ADD', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
ADD.transformArguments('key', [1, 2]),
|
||||
parseArgs(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 {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, values: Array<number>) {
|
||||
const args = ['TDIGEST.ADD', key];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, values: Array<number>) {
|
||||
parser.push('TDIGEST.ADD');
|
||||
parser.pushKey(key);
|
||||
|
||||
for (const value of values) {
|
||||
args.push(value.toString());
|
||||
parser.push(value.toString());
|
||||
}
|
||||
|
||||
return args;
|
||||
},
|
||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import BYRANK from './BYRANK';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TDIGEST.BYRANK', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
BYRANK.transformArguments('key', [1, 2]),
|
||||
parseArgs(BYRANK, 'key', [1, 2]),
|
||||
['TDIGEST.BYRANK', 'key', '1', '2']
|
||||
);
|
||||
});
|
||||
|
@@ -1,24 +1,25 @@
|
||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { transformDoubleArrayReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||
import { transformDoubleArrayReply } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export function transformByRankArguments(
|
||||
command: RedisArgument,
|
||||
parser: CommandParser,
|
||||
key: RedisArgument,
|
||||
ranks: Array<number>
|
||||
) {
|
||||
const args = [command, key];
|
||||
parser.pushKey(key);
|
||||
|
||||
for (const rank of ranks) {
|
||||
args.push(rank.toString());
|
||||
parser.push(rank.toString());
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments: transformByRankArguments.bind(undefined, 'TDIGEST.BYRANK'),
|
||||
parseCommand(...args: Parameters<typeof transformByRankArguments>) {
|
||||
args[0].push('TDIGEST.BYRANK');
|
||||
transformByRankArguments(...args);
|
||||
},
|
||||
transformReply: transformDoubleArrayReply
|
||||
} as const satisfies Command;
|
||||
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import BYREVRANK from './BYREVRANK';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TDIGEST.BYREVRANK', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
BYREVRANK.transformArguments('key', [1, 2]),
|
||||
parseArgs(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';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: BYRANK.FIRST_KEY_INDEX,
|
||||
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
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import CDF from './CDF';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TDIGEST.CDF', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
CDF.transformArguments('key', [1, 2]),
|
||||
parseArgs(CDF, 'key', [1, 2]),
|
||||
['TDIGEST.CDF', 'key', '1', '2']
|
||||
);
|
||||
});
|
||||
|
@@ -1,17 +1,16 @@
|
||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { transformDoubleArrayReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||
import { transformDoubleArrayReply } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument, values: Array<number>) {
|
||||
const args = ['TDIGEST.CDF', key];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, values: Array<number>) {
|
||||
parser.push('TDIGEST.CDF');
|
||||
parser.pushKey(key);
|
||||
|
||||
for (const item of values) {
|
||||
args.push(item.toString());
|
||||
parser.push(item.toString());
|
||||
}
|
||||
|
||||
return args;
|
||||
},
|
||||
transformReply: transformDoubleArrayReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,19 +1,20 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import CREATE from './CREATE';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TDIGEST.CREATE', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('without options', () => {
|
||||
assert.deepEqual(
|
||||
CREATE.transformArguments('key'),
|
||||
parseArgs(CREATE, 'key'),
|
||||
['TDIGEST.CREATE', 'key']
|
||||
);
|
||||
});
|
||||
|
||||
it('with COMPRESSION', () => {
|
||||
assert.deepEqual(
|
||||
CREATE.transformArguments('key', {
|
||||
parseArgs(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 {
|
||||
COMPRESSION?: number;
|
||||
}
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, options?: TDigestCreateOptions) {
|
||||
const args = ['TDIGEST.CREATE', key];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, options?: TDigestCreateOptions) {
|
||||
parser.push('TDIGEST.CREATE');
|
||||
parser.pushKey(key);
|
||||
|
||||
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'>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import INFO from './INFO';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TDIGEST.INFO', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
INFO.transformArguments('key'),
|
||||
parseArgs(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';
|
||||
|
||||
export type TdInfoReplyMap = TuplesToMapReply<[
|
||||
@@ -14,10 +15,10 @@ export type TdInfoReplyMap = TuplesToMapReply<[
|
||||
]>;
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument) {
|
||||
return ['TDIGEST.INFO', key];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||
parser.push('TDIGEST.INFO');
|
||||
parser.pushKey(key);
|
||||
},
|
||||
transformReply: {
|
||||
2: (reply: UnwrapReply<Resp2Reply<TdInfoReplyMap>>, _, typeMapping?: TypeMapping): TdInfoReplyMap => {
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import MAX from './MAX';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TDIGEST.MAX', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
MAX.transformArguments('key'),
|
||||
parseArgs(MAX, 'key'),
|
||||
['TDIGEST.MAX', 'key']
|
||||
);
|
||||
});
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { transformDoubleReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||
import { transformDoubleReply } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument) {
|
||||
return ['TDIGEST.MAX', key];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||
parser.push('TDIGEST.MAX');
|
||||
parser.pushKey(key);
|
||||
},
|
||||
transformReply: transformDoubleReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,20 +1,21 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import MERGE from './MERGE';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TDIGEST.MERGE', () => {
|
||||
describe('transformArguments', () => {
|
||||
describe('source', () => {
|
||||
it('string', () => {
|
||||
assert.deepEqual(
|
||||
MERGE.transformArguments('destination', 'source'),
|
||||
parseArgs(MERGE, 'destination', 'source'),
|
||||
['TDIGEST.MERGE', 'destination', '1', 'source']
|
||||
);
|
||||
});
|
||||
|
||||
it('Array', () => {
|
||||
assert.deepEqual(
|
||||
MERGE.transformArguments('destination', ['1', '2']),
|
||||
parseArgs(MERGE, 'destination', ['1', '2']),
|
||||
['TDIGEST.MERGE', 'destination', '2', '1', '2']
|
||||
);
|
||||
});
|
||||
@@ -22,7 +23,7 @@ describe('TDIGEST.MERGE', () => {
|
||||
|
||||
it('with COMPRESSION', () => {
|
||||
assert.deepEqual(
|
||||
MERGE.transformArguments('destination', 'source', {
|
||||
parseArgs(MERGE, 'destination', 'source', {
|
||||
COMPRESSION: 100
|
||||
}),
|
||||
['TDIGEST.MERGE', 'destination', '1', 'source', 'COMPRESSION', '100']
|
||||
@@ -31,7 +32,7 @@ describe('TDIGEST.MERGE', () => {
|
||||
|
||||
it('with OVERRIDE', () => {
|
||||
assert.deepEqual(
|
||||
MERGE.transformArguments('destination', 'source', {
|
||||
parseArgs(MERGE, 'destination', 'source', {
|
||||
OVERRIDE: true
|
||||
}),
|
||||
['TDIGEST.MERGE', 'destination', '1', 'source', 'OVERRIDE']
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { RedisVariadicArgument, pushVariadicArgument } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, SimpleStringReply, Command } from '@redis/client/lib/RESP/types';
|
||||
import { RedisVariadicArgument } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export interface TDigestMergeOptions {
|
||||
COMPRESSION?: number;
|
||||
@@ -7,24 +8,24 @@ export interface TDigestMergeOptions {
|
||||
}
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(
|
||||
parseCommand(
|
||||
parser: CommandParser,
|
||||
destination: RedisArgument,
|
||||
source: RedisVariadicArgument,
|
||||
options?: TDigestMergeOptions
|
||||
) {
|
||||
const args = pushVariadicArgument(['TDIGEST.MERGE', destination], source);
|
||||
parser.push('TDIGEST.MERGE');
|
||||
parser.pushKey(destination);
|
||||
parser.pushKeysLength(source);
|
||||
|
||||
if (options?.COMPRESSION !== undefined) {
|
||||
args.push('COMPRESSION', options.COMPRESSION.toString());
|
||||
parser.push('COMPRESSION', options.COMPRESSION.toString());
|
||||
}
|
||||
|
||||
if (options?.OVERRIDE) {
|
||||
args.push('OVERRIDE');
|
||||
parser.push('OVERRIDE');
|
||||
}
|
||||
|
||||
return args;
|
||||
},
|
||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import MIN from './MIN';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TDIGEST.MIN', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
MIN.transformArguments('key'),
|
||||
parseArgs(MIN, 'key'),
|
||||
['TDIGEST.MIN', 'key']
|
||||
);
|
||||
});
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { transformDoubleReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||
import { transformDoubleReply } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument) {
|
||||
return ['TDIGEST.MIN', key];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||
parser.push('TDIGEST.MIN');
|
||||
parser.pushKey(key);
|
||||
},
|
||||
transformReply: transformDoubleReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import QUANTILE from './QUANTILE';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TDIGEST.QUANTILE', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
QUANTILE.transformArguments('key', [1, 2]),
|
||||
parseArgs(QUANTILE, 'key', [1, 2]),
|
||||
['TDIGEST.QUANTILE', 'key', '1', '2']
|
||||
);
|
||||
});
|
||||
|
@@ -1,17 +1,16 @@
|
||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { transformDoubleArrayReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||
import { transformDoubleArrayReply } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument, quantiles: Array<number>) {
|
||||
const args = ['TDIGEST.QUANTILE', key];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, quantiles: Array<number>) {
|
||||
parser.push('TDIGEST.QUANTILE');
|
||||
parser.pushKey(key);
|
||||
|
||||
for (const quantile of quantiles) {
|
||||
args.push(quantile.toString());
|
||||
parser.push(quantile.toString());
|
||||
}
|
||||
|
||||
return args;
|
||||
},
|
||||
transformReply: transformDoubleArrayReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import RANK from './RANK';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TDIGEST.RANK', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
RANK.transformArguments('key', [1, 2]),
|
||||
parseArgs(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(
|
||||
command: RedisArgument,
|
||||
parser: CommandParser,
|
||||
key: RedisArgument,
|
||||
values: Array<number>
|
||||
) {
|
||||
const args = [command, key];
|
||||
parser.pushKey(key);
|
||||
|
||||
for (const value of values) {
|
||||
args.push(value.toString());
|
||||
parser.push(value.toString());
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
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>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import RESET from './RESET';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TDIGEST.RESET', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
RESET.transformArguments('key'),
|
||||
parseArgs(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 {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument) {
|
||||
return ['TDIGEST.RESET', key];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||
parser.push('TDIGEST.RESET');
|
||||
parser.pushKey(key);
|
||||
},
|
||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import REVRANK from './REVRANK';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TDIGEST.REVRANK', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
REVRANK.transformArguments('key', [1, 2]),
|
||||
parseArgs(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';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: RANK.FIRST_KEY_INDEX,
|
||||
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
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import TRIMMED_MEAN from './TRIMMED_MEAN';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TDIGEST.TRIMMED_MEAN', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
TRIMMED_MEAN.transformArguments('key', 0, 1),
|
||||
parseArgs(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 { transformDoubleReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||
import { transformDoubleReply } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(
|
||||
parseCommand(
|
||||
parser: CommandParser,
|
||||
key: RedisArgument,
|
||||
lowCutPercentile: number,
|
||||
highCutPercentile: number
|
||||
) {
|
||||
return [
|
||||
'TDIGEST.TRIMMED_MEAN',
|
||||
key,
|
||||
lowCutPercentile.toString(),
|
||||
highCutPercentile.toString()
|
||||
];
|
||||
parser.push('TDIGEST.TRIMMED_MEAN');
|
||||
parser.pushKey(key);
|
||||
parser.push(lowCutPercentile.toString(), highCutPercentile.toString());
|
||||
},
|
||||
transformReply: transformDoubleReply
|
||||
} 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 BYRANK from './BYRANK';
|
||||
import BYREVRANK from './BYREVRANK';
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import ADD from './ADD';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TOPK.ADD', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
ADD.transformArguments('key', 'item'),
|
||||
parseArgs(ADD, 'key', 'item'),
|
||||
['TOPK.ADD', 'key', 'item']
|
||||
);
|
||||
});
|
||||
|
@@ -1,11 +1,13 @@
|
||||
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '@redis/client/lib/RESP/types';
|
||||
import { RedisVariadicArgument } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, items: RedisVariadicArgument) {
|
||||
return pushVariadicArguments(['TOPK.ADD', key], items);
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, items: RedisVariadicArgument) {
|
||||
parser.push('TOPK.ADD');
|
||||
parser.pushKey(key);
|
||||
parser.pushVariadic(items);
|
||||
},
|
||||
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import COUNT from './COUNT';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TOPK.COUNT', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
COUNT.transformArguments('key', 'item'),
|
||||
parseArgs(COUNT, 'key', 'item'),
|
||||
['TOPK.COUNT', 'key', 'item']
|
||||
);
|
||||
});
|
||||
|
@@ -1,11 +1,13 @@
|
||||
import { RedisArgument, ArrayReply, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { RedisVariadicArgument, pushVariadicArguments } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, ArrayReply, NumberReply, Command } from '@redis/client/lib/RESP/types';
|
||||
import { RedisVariadicArgument } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument, items: RedisVariadicArgument) {
|
||||
return pushVariadicArguments(['TOPK.COUNT', key], items);
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, items: RedisVariadicArgument) {
|
||||
parser.push('TOPK.COUNT');
|
||||
parser.pushKey(key);
|
||||
parser.pushVariadic(items);
|
||||
},
|
||||
transformReply: undefined as unknown as () => ArrayReply<NumberReply>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,12 +1,13 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import INCRBY from './INCRBY';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TOPK.INCRBY', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('single item', () => {
|
||||
assert.deepEqual(
|
||||
INCRBY.transformArguments('key', {
|
||||
parseArgs(INCRBY, 'key', {
|
||||
item: 'item',
|
||||
incrementBy: 1
|
||||
}),
|
||||
@@ -16,7 +17,7 @@ describe('TOPK.INCRBY', () => {
|
||||
|
||||
it('multiple items', () => {
|
||||
assert.deepEqual(
|
||||
INCRBY.transformArguments('key', [{
|
||||
parseArgs(INCRBY, 'key', [{
|
||||
item: 'a',
|
||||
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 {
|
||||
item: string;
|
||||
incrementBy: number;
|
||||
}
|
||||
|
||||
function pushIncrByItem(args: Array<RedisArgument>, { item, incrementBy }: TopKIncrByItem) {
|
||||
args.push(item, incrementBy.toString());
|
||||
function pushIncrByItem(parser: CommandParser, { item, incrementBy }: TopKIncrByItem) {
|
||||
parser.push(item, incrementBy.toString());
|
||||
}
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(
|
||||
parseCommand(
|
||||
parser: CommandParser,
|
||||
key: RedisArgument,
|
||||
items: TopKIncrByItem | Array<TopKIncrByItem>
|
||||
) {
|
||||
const args = ['TOPK.INCRBY', key];
|
||||
parser.push('TOPK.INCRBY');
|
||||
parser.pushKey(key);
|
||||
|
||||
if (Array.isArray(items)) {
|
||||
for (const item of items) {
|
||||
pushIncrByItem(args, item);
|
||||
pushIncrByItem(parser, item);
|
||||
}
|
||||
} else {
|
||||
pushIncrByItem(args, items);
|
||||
pushIncrByItem(parser, items);
|
||||
}
|
||||
|
||||
return args;
|
||||
},
|
||||
transformReply: undefined as unknown as () => ArrayReply<SimpleStringReply | NullReply>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import INFO from './INFO';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TOPK INFO', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
INFO.transformArguments('key'),
|
||||
parseArgs(INFO, 'key'),
|
||||
['TOPK.INFO', 'key']
|
||||
);
|
||||
});
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import { transformDoubleReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { RedisArgument, TuplesToMapReply, NumberReply, DoubleReply, UnwrapReply, Resp2Reply, Command, SimpleStringReply, TypeMapping } from '@redis/client/dist/lib/RESP/types';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
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';
|
||||
|
||||
export type TopKInfoReplyMap = TuplesToMapReply<[
|
||||
@@ -10,10 +11,10 @@ export type TopKInfoReplyMap = TuplesToMapReply<[
|
||||
]>;
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument) {
|
||||
return ['TOPK.INFO', key];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||
parser.push('TOPK.INFO');
|
||||
parser.pushKey(key);
|
||||
},
|
||||
transformReply: {
|
||||
2: (reply: UnwrapReply<Resp2Reply<TopKInfoReplyMap>>, preserve?: any, typeMapping?: TypeMapping): TopKInfoReplyMap => {
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import LIST from './LIST';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TOPK.LIST', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
LIST.transformArguments('key'),
|
||||
parseArgs(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 {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument) {
|
||||
return ['TOPK.LIST', key];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||
parser.push('TOPK.LIST');
|
||||
parser.pushKey(key);
|
||||
},
|
||||
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,13 +1,14 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import LIST_WITHCOUNT from './LIST_WITHCOUNT';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TOPK.LIST WITHCOUNT', () => {
|
||||
testUtils.isVersionGreaterThanHook([2, 2, 9]);
|
||||
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
LIST_WITHCOUNT.transformArguments('key'),
|
||||
parseArgs(LIST_WITHCOUNT, 'key'),
|
||||
['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 {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument) {
|
||||
return ['TOPK.LIST', key, 'WITHCOUNT'];
|
||||
parseCommand(parser: CommandParser, key: RedisArgument) {
|
||||
parser.push('TOPK.LIST');
|
||||
parser.pushKey(key);
|
||||
parser.push('WITHCOUNT');
|
||||
},
|
||||
transformReply(rawReply: UnwrapReply<ArrayReply<BlobStringReply | NumberReply>>) {
|
||||
const reply: Array<{
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import QUERY from './QUERY';
|
||||
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
describe('TOPK.QUERY', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
QUERY.transformArguments('key', 'item'),
|
||||
parseArgs(QUERY, 'key', 'item'),
|
||||
['TOPK.QUERY', 'key', 'item']
|
||||
);
|
||||
});
|
||||
|
@@ -1,11 +1,13 @@
|
||||
import { RedisArgument, Command } from '@redis/client/dist/lib/RESP/types';
|
||||
import { RedisVariadicArgument, pushVariadicArguments, transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
||||
import { CommandParser } from '@redis/client/lib/client/parser';
|
||||
import { RedisArgument, Command } from '@redis/client/lib/RESP/types';
|
||||
import { RedisVariadicArgument, transformBooleanArrayReply } from '@redis/client/lib/commands/generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, items: RedisVariadicArgument) {
|
||||
return pushVariadicArguments(['TOPK.QUERY', key], items);
|
||||
parseCommand(parser: CommandParser, key: RedisArgument, items: RedisVariadicArgument) {
|
||||
parser.push('TOPK.QUERY');
|
||||
parser.pushKey(key);
|
||||
parser.pushVariadic(items);
|
||||
},
|
||||
transformReply: transformBooleanArrayReply
|
||||
} as const satisfies Command;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user