-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.cjs
More file actions
37 lines (27 loc) · 764 Bytes
/
script.cjs
File metadata and controls
37 lines (27 loc) · 764 Bytes
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
/* eslint-disable no-undef */
// Connect to redis using env variables
const redis = require("redis");
const HOST = process.env.REDIS_HOST;
const PORT = process.env.REDIS_PORT;
console.log("Using Redis host and port:", HOST, PORT);
const client = redis.createClient({
host: HOST,
port: PORT,
});
client.on("error", (err) => console.log("Redis Client Error", err));
client.on("connect", () => {
console.log("Redis Client Connected to Server");
client.set("mykey", "Hello World!").then(() => {
client.get("mykey").then((value) => {
console.log(value);
client.quit();
});
});
});
client.connect();
// Set a value
setTimeout(() => {
console.log("Forced exit");
process.exit(0);
}, 6000);
console.log("Redis script invoked");