Do I need to exit my node redis client instance using .quit ()?

Looking at this code below (taken from 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 rolls for me? I am trying to debug a memory leak in my redis and I realized that I am not using .quit () anywhere. Should I be?

Sense, should my code look like this?

client = redis.createClient();
multi = clent.multi();
multi.exec( {something} );
client.quit();

Basically, where does client.quit go and what do I even need?

+2
source share
1 answer

"MULTI commands are queued before the release of EXEC, and then all commands are run atomically using Redis."

This is an example from github:

// multi chain with an individual callback
client.multi()
    .scard("bigset")
    .smembers("bigset")
    .keys("*", function (err, replies) {
        client.mget(replies, redis.print);
    })
    .dbsize()
    .exec(function (err, replies) {
        console.log("MULTI got " + replies.length + " replies");
        replies.forEach(function (reply, index) {
            console.log("Reply " + index + ": " + reply.toString());
        });
    });

: client.quit()? , , redis- , redis. client.quit(), . (, )

+6

All Articles