Article From:

I want to save redis when I visit test, but I can’t succeed. If I mention client, I will have it. Why?

Used express

Why do not follow the following

var redis = require('redis');
var client = redis.createClient()
//  Can printClient.on ("ready", function () {()Console.log ("client ready success")})/ / / no consoleApp.get ('/teSt', function (req, res, next) {/ / console.log (client)Client.on ("ready", function () {()Console.log("ready success")})})

Answer 0:

You have set up callback function outside, and inside it is repeated settings.

Answer 1:

When a connection is created, it will triggerready,When visiting/test At the time,ready The incident has actually started, and the callback of the modified monitor will not be reprinted.
I understand what you mean to be visiting/test When you execute some orders, you can probably do this:

app.get('/test', function (req, res, next) {
-  client.on("ready",function(){
-    console.log("ready"Success"-})+ client.set ('key','value')})

Link of this Article: Redis is not executed on the route

Leave a Reply

Your email address will not be published. Required fields are marked *