-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathredisTest.js
44 lines (38 loc) · 1.11 KB
/
redisTest.js
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
import redis from "redis";
import readline from "node:readline";
// const rl = readline.createInterface({
// input: process.stdin,
// output: process.stdout,
// });
const pub = redis.createClient();
pub.connect();
// (async function () {
// await pub.zAdd("test",{score:100, value:"a"});
// await pub.zAdd("test",{score:150,value:"bcd"});
// console.log(await pub.zRangeByScoreWithScores("test",0,160));
// for(let player of await pub.zRangeWithScores("test",0,-1)){
// console.log(player);
// }
// //console.log(list);
// await pub.quit();
// })();
// (async function(){
// console.log("result:", await main());
// })();
// rl.on("line", (input) => {
// pub.publish("test", input);
// });
// function main() {
// const sub = redis.createClient();
// sub.connect();
// return new Promise ((resolve)=>{
// sub.subscribe("test",(response)=>{
// console.log("=>",response);
// if (response==="close"){
// sub.unsubscribe("test");
// sub.quit();
// resolve(response);
// }
// });
// })
// }