📜  nodejs pub sub redis - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:32.312000             🧑  作者: Mango

代码示例2
1const express = require("express")
2const redis = require("redis")
3
4const publisher = redis.createClient()
5
6const app = express()
7
8app.get("/", (req, res) => {
9  const user = {
10    id: "123456",
11    name: "Davis",
12  }
13
14  publisher.publish("user-notify", JSON.stringify(user))
15  res.send("Publishing an Event using Redis")
16})
17
18app.listen(3005, () => {
19  console.log(`server is listening on PORT 3005`)
20})