-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
executor.ts
47 lines (40 loc) · 987 Bytes
/
executor.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import type { Connection, SendCommandOptions } from "./connection.ts";
import type { RedisReply, RedisValue } from "./protocol/shared/types.ts";
export interface CommandExecutor {
readonly connection: Connection;
/**
* @deprecated
*/
exec(
command: string,
...args: RedisValue[]
): Promise<RedisReply>;
sendCommand(
command: string,
args?: RedisValue[],
options?: SendCommandOptions,
): Promise<RedisReply>;
/**
* Closes a redis connection.
*/
close(): void;
}
export class DefaultExecutor implements CommandExecutor {
constructor(readonly connection: Connection) {}
exec(
command: string,
...args: RedisValue[]
): Promise<RedisReply> {
return this.connection.sendCommand(command, args);
}
sendCommand(
command: string,
args?: RedisValue[],
options?: SendCommandOptions,
) {
return this.connection.sendCommand(command, args, options);
}
close(): void {
this.connection.close();
}
}