You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
* (docs) bloom: add jsdocs for all commands * (docs) json: add jsdocs * (docs) search: add jsdocs for all commands * (docs) jsdocs for std commands * (docs) jsdoc comments to time series commands
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
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,
|
|
/**
|
|
* Adds one or more items to a Cuckoo Filter, creating it if it does not exist
|
|
* @param parser - The command parser
|
|
* @param key - The name of the Cuckoo filter
|
|
* @param items - One or more items to add to the filter
|
|
* @param options - Optional parameters for filter creation
|
|
* @param options.CAPACITY - The number of entries intended to be added to the filter
|
|
* @param options.NOCREATE - If true, prevents automatic filter creation
|
|
*/
|
|
parseCommand(...args: Parameters<typeof parseCfInsertArguments>) {
|
|
args[0].push('CF.INSERT');
|
|
parseCfInsertArguments(...args);
|
|
},
|
|
transformReply: transformBooleanArrayReply
|
|
} as const satisfies Command;
|