You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import { CommandParser } from '@redis/client/dist/lib/client/parser';
|
|
import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
|
|
import { Timestamp, transformTimestampArgument, parseRetentionArgument, parseChunkSizeArgument, Labels, parseLabelsArgument, parseIgnoreArgument } from '.';
|
|
import { TsIgnoreOptions } from './ADD';
|
|
|
|
export interface TsIncrByOptions {
|
|
TIMESTAMP?: Timestamp;
|
|
RETENTION?: number;
|
|
UNCOMPRESSED?: boolean;
|
|
CHUNK_SIZE?: number;
|
|
LABELS?: Labels;
|
|
IGNORE?: TsIgnoreOptions;
|
|
}
|
|
|
|
export function parseIncrByArguments(
|
|
parser: CommandParser,
|
|
key: RedisArgument,
|
|
value: number,
|
|
options?: TsIncrByOptions
|
|
) {
|
|
parser.pushKey(key);
|
|
parser.push(value.toString());
|
|
|
|
if (options?.TIMESTAMP !== undefined && options?.TIMESTAMP !== null) {
|
|
parser.push('TIMESTAMP', transformTimestampArgument(options.TIMESTAMP));
|
|
}
|
|
|
|
parseRetentionArgument(parser, options?.RETENTION);
|
|
|
|
if (options?.UNCOMPRESSED) {
|
|
parser.push('UNCOMPRESSED');
|
|
}
|
|
|
|
parseChunkSizeArgument(parser, options?.CHUNK_SIZE);
|
|
|
|
parseLabelsArgument(parser, options?.LABELS);
|
|
|
|
parseIgnoreArgument(parser, options?.IGNORE);
|
|
}
|
|
|
|
export default {
|
|
IS_READ_ONLY: false,
|
|
parseCommand(...args: Parameters<typeof parseIncrByArguments>) {
|
|
const parser = args[0];
|
|
|
|
parser.push('TS.INCRBY');
|
|
parseIncrByArguments(...args);
|
|
},
|
|
transformReply: undefined as unknown as () => NumberReply
|
|
} as const satisfies Command;
|