I have a socket.io server using redis called "server.js" that fires up a node server. Currently it is something like this:
var client = redis.createClient()
var io = require('socket.io').listen(80);
io.sockets.on('connection', function (socket) {
client.set(); // do something with redis
});
Then I fire up my server and it just stays alive. Is this wrong? Should it be like this?
var io = require('socket.io').listen(80);
io.sockets.on('connection', function (socket) {
var client = redis.createClient()
client.set(); // do something with redis
client.quit();
});
Am I supposed to keep opening and closing redis, or can I just open it once and leave it open? Which one of the above snippets is the proper way to start a server?