1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-03 04:01:40 +03:00
Files
node-redis/packages/graph/lib/commands/SLOWLOG.ts
2024-11-04 12:21:17 -05:00

29 lines
867 B
TypeScript

import { RedisArgument, ArrayReply, TuplesReply, BlobStringReply, UnwrapReply, Command } from '@redis/client/dist/lib/RESP/types';
import { CommandParser } from '@redis/client/dist/lib/client/parser';
type SlowLogRawReply = ArrayReply<TuplesReply<[
timestamp: BlobStringReply,
command: BlobStringReply,
query: BlobStringReply,
took: BlobStringReply
]>>;
export default {
IS_READ_ONLY: true,
parseCommand(parser: CommandParser, key: RedisArgument) {
parser.push('GRAPH.SLOWLOG');
parser.pushKey(key);
},
transformReply(reply: UnwrapReply<SlowLogRawReply>) {
return reply.map(log => {
const [timestamp, command, query, took] = log as unknown as UnwrapReply<typeof log>;
return {
timestamp: Number(timestamp),
command,
query,
took: Number(took)
};
});
}
} as const satisfies Command;