Open Napas opened 9 years ago
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!');
});
}
I'm trying to use hmset:
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. (/srv/http/pagetag-js-test/node_modules/redis-cluster/node_modules/redis/index.js:308:18)
at ReplyParser.emit (events.js:95:17)
at ReplyParser.send_error (/srv/http/pagetag-js-test/node_modules/redis-cluster/node_modules/redis/lib/parser/javascript.js:296:10)
at ReplyParser.execute (/srv/http/pagetag-js-test/node_modules/redis-cluster/node_modules/redis/lib/parser/javascript.js:181:22)
at RedisClient.on_data (/srv/http/pagetag-js-test/node_modules/redis-cluster/node_modules/redis/index.js:535:27)
at Socket. (/srv/http/pagetag-js-test/node_modules/redis-cluster/node_modules/redis/index.js:91:14)
at Socket.emit (events.js:95:17)
at Socket. (_stream_readable.js:765:14)
So what is correct way to use hmset function?