You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-03 04:01:40 +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
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { CommandParser } from '../client/parser';
|
|
import { RedisVariadicArgument, transformEXAT } from './generic-transformers';
|
|
import { ArrayReply, Command, NumberReply, RedisArgument } from '../RESP/types';
|
|
|
|
export default {
|
|
/**
|
|
* Sets the expiration for hash fields at a specific Unix timestamp
|
|
* @param parser - The Redis command parser
|
|
* @param key - Key of the hash
|
|
* @param fields - Fields to set expiration on
|
|
* @param timestamp - Unix timestamp (seconds since January 1, 1970) or Date object
|
|
* @param mode - Expiration mode: NX (only if field has no expiry), XX (only if field has existing expiry), GT (only if new expiry is greater than current), LT (only if new expiry is less than current)
|
|
*/
|
|
parseCommand(
|
|
parser: CommandParser,
|
|
key: RedisArgument,
|
|
fields: RedisVariadicArgument,
|
|
timestamp: number | Date,
|
|
mode?: 'NX' | 'XX' | 'GT' | 'LT'
|
|
) {
|
|
parser.push('HEXPIREAT');
|
|
parser.pushKey(key);
|
|
parser.push(transformEXAT(timestamp));
|
|
|
|
if (mode) {
|
|
parser.push(mode);
|
|
}
|
|
|
|
parser.push('FIELDS')
|
|
|
|
parser.pushVariadicWithLength(fields);
|
|
},
|
|
transformReply: undefined as unknown as () => ArrayReply<NumberReply>
|
|
} as const satisfies Command;
|