node_redis_cluster
node_redis_cluster copied to clipboard
hmset error
I'm trying to use hmset:
redisConnection.hmset(personId, {
tagId: req.params.tagId,
personHash: req.params.personHash
}, function(err, reply) {
if (err) {
throw err;
}
assert(reply, 'OK');
});
And got error:
/app/node_modules/redis-cluster/node_modules/redis/index.js:563
throw callback_err;
^
TypeError: Object Error: ERR wrong number of arguments for 'hmset' command has no method 'substr'
at Command.callback (/srv/http/pagetag-js-test/node_modules/redis-cluster/index.js:181:18)
at RedisClient.return_error (/srv/http/pagetag-js-test/node_modules/redis-cluster/node_modules/redis/index.js:559:25)
at ReplyParser.
So what is correct way to use hmset function?
I think problem at "personId", try "personId.toString()" please
Same error. hset works with personId.
Very strange, can you please provide more code, how you init redis-cluster etc...
And what OS you are using?
var cluster = require('cluster');
if (cluster.isMaster) {
// Count the machine's CPUs
var cpuCount = require('os').cpus().length;
// Create a worker for each CPU
for (var i = 0; i < cpuCount; i += 1) {
cluster.fork();
}
} else {
var express = require('express');
var app = express();
var sha1 = require('sha1');
var redis = require('redis-cluster').clusterClient;
var assert = require('assert');
var crypto = require('crypto');
new redis.clusterInstance('127.0.0.1:6379', function(err, redisConnection) {
if (err) {
throw err;
}
app.get(
'/test-url/:personHash/:tagId',
function(req, res) {
var personId = sha1(crypto.randomBytes(24).toString('hex'));
...
redisConnection.hmset(personId, {
tagId: req.params.tagId,
personHash: req.params.personHash
}, function(err, reply) {
if (err) {
throw err;
}
assert(reply, 'OK');
});
});
app.listen(3000);
console.log('Application running!');
});
}