You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
38 lines
1005 B
TypeScript
38 lines
1005 B
TypeScript
import { CommandParser } from '@redis/client/dist/lib/client/parser';
|
|
import { Command, RedisArgument } from '@redis/client/dist/lib/RESP/types';
|
|
import { RedisVariadicArgument, transformBooleanArrayReply } from '@redis/client/dist/lib/commands/generic-transformers';
|
|
|
|
export interface CfInsertOptions {
|
|
CAPACITY?: number;
|
|
NOCREATE?: boolean;
|
|
}
|
|
|
|
export function parseCfInsertArguments(
|
|
parser: CommandParser,
|
|
key: RedisArgument,
|
|
items: RedisVariadicArgument,
|
|
options?: CfInsertOptions
|
|
) {
|
|
parser.pushKey(key);
|
|
|
|
if (options?.CAPACITY !== undefined) {
|
|
parser.push('CAPACITY', options.CAPACITY.toString());
|
|
}
|
|
|
|
if (options?.NOCREATE) {
|
|
parser.push('NOCREATE');
|
|
}
|
|
|
|
parser.push('ITEMS');
|
|
parser.pushVariadic(items);
|
|
}
|
|
|
|
export default {
|
|
IS_READ_ONLY: false,
|
|
parseCommand(...args: Parameters<typeof parseCfInsertArguments>) {
|
|
args[0].push('CF.INSERT');
|
|
parseCfInsertArguments(...args);
|
|
},
|
|
transformReply: transformBooleanArrayReply
|
|
} as const satisfies Command;
|