You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Merge branch 'master' of https://github.com/mciparelli/node_redis into mciparelli-master
This commit is contained in:
9
index.js
9
index.js
@@ -668,7 +668,7 @@ function Command(command, args, sub_command, buffer_args, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RedisClient.prototype.send_command = function (command, args, callback) {
|
RedisClient.prototype.send_command = function (command, args, callback) {
|
||||||
var arg, command_obj, i, il, elem_count, buffer_args, stream = this.stream, command_str = "", buffered_writes = 0, last_arg_type;
|
var arg, command_obj, i, il, elem_count, buffer_args, stream = this.stream, command_str = "", buffered_writes = 0, last_arg_type, lcaseCommand;
|
||||||
|
|
||||||
if (typeof command !== "string") {
|
if (typeof command !== "string") {
|
||||||
throw new Error("First argument to send_command must be the command name string, not " + typeof command);
|
throw new Error("First argument to send_command must be the command name string, not " + typeof command);
|
||||||
@@ -698,11 +698,12 @@ RedisClient.prototype.send_command = function (command, args, callback) {
|
|||||||
throw new Error("send_command: second argument must be an array");
|
throw new Error("send_command: second argument must be an array");
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the last argument is an array and command is sadd, expand it out:
|
// if the last argument is an array and command is sadd or srem, expand it out:
|
||||||
// client.sadd(arg1, [arg2, arg3, arg4], cb);
|
// client.sadd(arg1, [arg2, arg3, arg4], cb);
|
||||||
// converts to:
|
// converts to:
|
||||||
// client.sadd(arg1, arg2, arg3, arg4, cb);
|
// client.sadd(arg1, arg2, arg3, arg4, cb);
|
||||||
if ((command === 'sadd' || command === 'SADD') && args.length > 0 && Array.isArray(args[args.length - 1])) {
|
lcaseCommand = command.toLowerCase();
|
||||||
|
if ((lcaseCommand === 'sadd' || lcaseCommand === 'srem') && args.length > 0 && Array.isArray(args[args.length - 1])) {
|
||||||
args = args.slice(0, -1).concat(args[args.length - 1]);
|
args = args.slice(0, -1).concat(args[args.length - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -713,7 +714,7 @@ RedisClient.prototype.send_command = function (command, args, callback) {
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer_args = false;
|
buffer_args = false;
|
||||||
for (i = 0, il = args.length, arg; i < il; i += 1) {
|
for (i = 0, il = args.length, arg; i < il; i += 1) {
|
||||||
if (Buffer.isBuffer(args[i])) {
|
if (Buffer.isBuffer(args[i])) {
|
||||||
|
21
test.js
21
test.js
@@ -1292,6 +1292,27 @@ tests.SREM = function () {
|
|||||||
client.scard('set0', last(name, require_number(0, name)));
|
client.scard('set0', last(name, require_number(0, name)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
tests.SREM2 = function () {
|
||||||
|
var name = "SREM2";
|
||||||
|
client.del("set0");
|
||||||
|
client.sadd("set0", ["member0", "member1", "member2"], require_number(3, name));
|
||||||
|
client.SREM("set0", ["member1", "member2"], require_number(2, name));
|
||||||
|
client.smembers("set0", function (err, res) {
|
||||||
|
assert.strictEqual(res.length, 1);
|
||||||
|
assert.ok(~res.indexOf("member0"));
|
||||||
|
});
|
||||||
|
client.sadd("set0", ["member3", "member4", "member5"], require_number(3, name));
|
||||||
|
client.srem("set0", ["member0", "member6"], require_number(1, name));
|
||||||
|
client.smembers("set0", function (err, res) {
|
||||||
|
assert.strictEqual(res.length, 3);
|
||||||
|
assert.ok(~res.indexOf("member3"));
|
||||||
|
assert.ok(~res.indexOf("member4"));
|
||||||
|
assert.ok(~res.indexOf("member5"));
|
||||||
|
next(name);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
tests.SPOP = function () {
|
tests.SPOP = function () {
|
||||||
var name = "SPOP";
|
var name = "SPOP";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user