You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-03 04:01:40 +03:00
29 lines
867 B
TypeScript
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;
|