You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
35 lines
975 B
TypeScript
35 lines
975 B
TypeScript
import { CommandParser } from '@redis/client/dist/lib/client/parser';
|
|
import { RedisArgument, TuplesReply, NumberReply, DoubleReply, UnwrapReply, Resp2Reply, Command } from '@redis/client/dist/lib/RESP/types';
|
|
|
|
export interface TsGetOptions {
|
|
LATEST?: boolean;
|
|
}
|
|
|
|
export type TsGetReply = TuplesReply<[]> | TuplesReply<[NumberReply, DoubleReply]>;
|
|
|
|
export default {
|
|
IS_READ_ONLY: true,
|
|
parseCommand(parser: CommandParser, key: RedisArgument, options?: TsGetOptions) {
|
|
parser.push('TS.GET');
|
|
parser.pushKey(key);
|
|
|
|
if (options?.LATEST) {
|
|
parser.push('LATEST');
|
|
}
|
|
},
|
|
transformReply: {
|
|
2(reply: UnwrapReply<Resp2Reply<TsGetReply>>) {
|
|
return reply.length === 0 ? null : {
|
|
timestamp: reply[0],
|
|
value: Number(reply[1])
|
|
};
|
|
},
|
|
3(reply: UnwrapReply<TsGetReply>) {
|
|
return reply.length === 0 ? null : {
|
|
timestamp: reply[0],
|
|
value: reply[1]
|
|
};
|
|
}
|
|
}
|
|
} as const satisfies Command;
|