Looking at this code below (taken from the git page)
var redis = require("redis"),
client = redis.createClient(), multi;
// runs immediately
client.mset("incr thing", 100, "incr other thing", 1, redis.print);
multi = client.multi();
// drains multi queue and runs atomically
multi.exec(function (err, replies) {
console.log(replies); // 101, 2
client.quit(); // IS THIS OPTIONAL?
});
I want to know if client.quit() is optional, or if multi.exec() automatically performs a quit for me? I'm trying to debug a memory leak in my redis and I realized I am not using .quit() anywhere. Should I be?
Meaning, should my code look like this?
client = redis.createClient();
multi = clent.multi();
multi.exec( {something} );
client.quit();
Basically, where does client.quit go and do I even need it?
"MULTI commands are queued up until an EXEC is issued, and then all commands are run atomically by Redis."
This is a example from github:
Your question: do i need to use
client.quit()
? Yes, you need to because your redis connection will not be closed until you restart your redis server. You should useclient.quit()
when all your process have been completed. (In your last callback for example)