Skip to content

Navigation Menu

Sign in
Appearance settings
Sign up
Appearance settings

Latest commit

History

History
History
39 lines (34 loc) 路 767 Bytes

File metadata and controls

39 lines (34 loc) 路 767 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import Redis, { Result, Callback } from "ioredis";
const redis = new Redis();
/**
* Define our command
*/
redis.defineCommand("myecho", {
numberOfKeys: 1,
lua: "return KEYS[1] .. ARGV[1]",
});
// Add declarations
declare module "ioredis" {
interface RedisCommander<Context> {
myecho(
key: string,
argv: string,
callback?: Callback<string>
): Result<string, Context>;
}
}
// Works with callbacks
redis.myecho("key", "argv", (err, result) => {
console.log("callback", result);
});
// Works with Promises
(async () => {
console.log("promise", await redis.myecho("key", "argv"));
})();
// Works with pipelining
redis
.pipeline()
.myecho("key", "argv")
.exec((err, result) => {
console.log("pipeline", result);
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.