1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

"forward port" changes from 4.6.9

This commit is contained in:
Leibale
2023-09-19 19:23:24 -04:00
parent 819ca71538
commit 099f16e45f
16 changed files with 306 additions and 260 deletions

View File

@@ -1,39 +1,40 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
export const FIRST_KEY_INDEX = 1;
interface RestoreOptions {
REPLACE?: true;
ABSTTL?: true;
IDLETIME?: number;
FREQ?: number;
export interface RestoreOptions {
REPLACE?: boolean;
ABSTTL?: boolean;
IDLETIME?: number;
FREQ?: number;
}
export function transformArguments(
key: RedisCommandArgument,
export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: false,
transformArguments(
key: RedisArgument,
ttl: number,
serializedValue: RedisCommandArgument,
serializedValue: RedisArgument,
options?: RestoreOptions
): RedisCommandArguments {
) {
const args = ['RESTORE', key, ttl.toString(), serializedValue];
if (options?.REPLACE) {
args.push('REPLACE');
args.push('REPLACE');
}
if (options?.ABSTTL) {
args.push('ABSTTL');
args.push('ABSTTL');
}
if (options?.IDLETIME) {
args.push('IDLETIME', options.IDLETIME.toString());
args.push('IDLETIME', options.IDLETIME.toString());
}
if (options?.FREQ) {
args.push('FREQ', options.FREQ.toString());
args.push('FREQ', options.FREQ.toString());
}
return args;
}
export declare function transformReply(): 'OK';
},
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
} as const satisfies Command;