You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
need not send message to server when set undefined value
This commit is contained in:
8
index.js
8
index.js
@@ -694,6 +694,14 @@ RedisClient.prototype.send_command = function (command, args, callback) {
|
|||||||
args = args.slice(0, -1).concat(args[args.length - 1]);
|
args = args.slice(0, -1).concat(args[args.length - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the value is undefined or null and command is set or setx, need not to send message to redis
|
||||||
|
if (command === 'set' || command === 'setex') {
|
||||||
|
if(args[args.length - 1] === undefined || args[args.length - 1] === null) {
|
||||||
|
var err = new Error('send_command: ' + command + ' value must not be undefined or null');
|
||||||
|
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])) {
|
||||||
|
2
test.js
2
test.js
@@ -1109,6 +1109,7 @@ tests.SET = function () {
|
|||||||
var name = "SET";
|
var name = "SET";
|
||||||
client.SET(["set key", "set val"], require_string("OK", name));
|
client.SET(["set key", "set val"], require_string("OK", name));
|
||||||
client.get(["set key"], last(name, require_string("set val", name)));
|
client.get(["set key"], last(name, require_string("set val", name)));
|
||||||
|
client.SET(["set key", undefined], require_error(name));
|
||||||
};
|
};
|
||||||
|
|
||||||
tests.GETSET = function () {
|
tests.GETSET = function () {
|
||||||
@@ -1161,6 +1162,7 @@ tests.SETEX = function () {
|
|||||||
client.SETEX(["setex key", "100", "setex val"], require_string("OK", name));
|
client.SETEX(["setex key", "100", "setex val"], require_string("OK", name));
|
||||||
client.exists(["setex key"], require_number(1, name));
|
client.exists(["setex key"], require_number(1, name));
|
||||||
client.ttl(["setex key"], last(name, require_number_pos(name)));
|
client.ttl(["setex key"], last(name, require_number_pos(name)));
|
||||||
|
client.SETEX(["setex key", "100", undefined], require_error(name));
|
||||||
};
|
};
|
||||||
|
|
||||||
tests.MSETNX = function () {
|
tests.MSETNX = function () {
|
||||||
|
Reference in New Issue
Block a user