You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
28 lines
778 B
TypeScript
28 lines
778 B
TypeScript
import { RedisArgument, ArrayReply, TuplesReply, BlobStringReply, UnwrapReply, Command } from '@redis/client/dist/lib/RESP/types';
|
|
|
|
type SlowLogRawReply = ArrayReply<TuplesReply<[
|
|
timestamp: BlobStringReply,
|
|
command: BlobStringReply,
|
|
query: BlobStringReply,
|
|
took: BlobStringReply
|
|
]>>;
|
|
|
|
export default {
|
|
FIRST_KEY_INDEX: 1,
|
|
IS_READ_ONLY: true,
|
|
transformArguments(key: RedisArgument) {
|
|
return ['GRAPH.SLOWLOG', 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;
|