Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

nodejs pub sub redis

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})
Source by cloudnweb.dev #
 
PREVIOUS NEXT
Tagged: #nodejs #pub #redis
ADD COMMENT
Topic
Name
9+7 =