joaojeronimo / node_redis_cluster Goto Github PK
View Code? Open in Web Editor NEWA thin wrapper over node_redis to make it work with Redis Cluster
A thin wrapper over node_redis to make it work with Redis Cluster
Did you know how PUB/SUB working in cluster?
Did it replicate message to each node or I need to do it over one specific node like regular redis?
Has anyone experienced a lot of slow down in basic Redis operations when using this implementation? I'm talking about 10 seconds or more when just using the example in the README.
When hashing for example this string:
nht.reach.accounts:زووم
the slot computed is 15073, while according to redis the slot is 4107
This causes an Error: MOVED 4107 ... that cannot be fixed.
Object everything works fine my code, gets to this line of code:
var multi = r.multi();
Object multi gets undefined. Do you have an idea maybe?
I should also mention, that if i use r.get and r.set the system works fine, but i should use transactions.
Referring to the redisLinks property that is exposed through module.exports
https://github.com/joaojeronimo/node_redis_cluster/blob/master/index.js#L317
In a project where there are multiple redis clusters being used, the redisLinks property will point to the nodes of the most recently created client. Given that a client can be created either by a user or by receiving a 'MOVED' command, there is almost no way of reliably determining what redisLinks is pointing to. Unless there is a really good reason for keeping redisLinks around, I am in favor of removing it from the API altogether.
In the function connectToLink the link that has to be parsed is in the form :@
When the client (fastRedis or normal client) is created the string @ is used as port and the connection fail.
The solution is changing the first line of code in the function with this two rows:
var ss = str.split('@');
var spl = ss[0].split(':');
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. (/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?
Hi.
We have had a problem where, when we try and quit the connection by client.quit()
the tcp connection to redis server is not actually quit/killed/ended.
it still remains and we got a lot of connections on redis server.
I just took a look at the code and could nto find a line of code which actually ended the stream connection.
Any updates on this would be really appriciated.
Hi, João,
I am trying to connect to a redis cluster (version 2.9.11) and I have the following error:
iMac-de-Carlos:loudspotter-node carlosballock$ sudo node server.js
/Users/carlosballock/node_modules/redis/index.js:582
throw err;
^
TypeError: Cannot call method 'split' of undefined
at /Users/carlosballock/node_modules/redis-cluster/index.js:42:30
at try_callback (/Users/carlosballock/node_modules/redis/index.js:579:9)
at RedisClient.return_reply (/Users/carlosballock/node_modules/redis/index.js:664:13)
at HiredisReplyParser. (/Users/carlosballock/node_modules/redis/index.js:312:14)
at HiredisReplyParser.EventEmitter.emit (events.js:95:17)
at HiredisReplyParser.execute (/Users/carlosballock/node_modules/redis/lib/parser/hiredis.js:43:18)
at RedisClient.on_data (/Users/carlosballock/node_modules/redis/index.js:535:27)
at Socket. (/Users/carlosballock/node_modules/redis/index.js:91:14)
at Socket.EventEmitter.emit (events.js:95:17)
at Socket. (_stream_readable.js:746:14)
The following is the result of calling "cluster nodes" in my cluster in 2 moments:
Moment 1:
8e9910e26febc9a2122c03f62beee4d589436b24 :0 myself,master - 0 0 0 connected
Moment 2:
dd6e13b627a9b54337ec4718119ebddb99902cb0 127.0.0.1:6381 master - 0 1381638532662 0 connected 10922-16383
8e9910e26febc9a2122c03f62beee4d589436b24 :0 myself,master - 0 0 0 connected 0-5460
349630e9c51ae4b41aefdbab2511644b3512dc1d 127.0.0.1:6380 master - 0 1381638532662 0 connected 5461-10921
Shouldn't the "connectToNodesOfCluster" function be like this? (refer to the FIXME comments below)
function connectToNodesOfCluster (firstLink, callback) {
var redisLinks = [];
var fireStarter = connectToLink(firstLink);
fireStarter.cluster('nodes', function(err, nodes) {
if (err) {
callback(err, null);
return;
}
var lines = nodes.split('\n');
var n = lines.length -1;
while (n--) {
var items = lines[n].split(' ');
var name = items[0];
var flags = items[2];
var link = ( flags === 'myself' || flags === 'myself,master') ? firstLink : items[1];
var linkState = items[7]; // FIXME: this index was incremented;
if (lines.length === 1 && lines[1] === '') {
var slots = [0, 16383]
} else {
var slots = items[8].split('-'); // FIXME: this index was also incremented;
}
console.log(linkState);
if (linkState === 'connected') {
redisLinks.push({name: name, link: connectToLink(link), slots: slots});
}
if (n === 0) {
console.log(redisLinks);
callback(err, redisLinks);
}
}
});
}
In both of these moments, the same error occurred. Please, can you help me with that?
Regards,
Carlos.
Hi Joao, first, congratulations with the cluster lib, everything for my app is working after refactor, but i notice the version of the redis inside node_redis_cluster is too old 0.8.x and today we are @ 2.2.3 with a lot of enhancements & commands.
Are u thinking in repacking the node_redis_cluster with the latest node_redis?
If not could u show me the way?
tanx!
I am using the poor man cluster client to run a basic lua script:
"return redis.call('GET', 'foo')"
but the client is not able to recognize where the key "foo" is stored.
Is there a way to do this besides parsing CLUSTER SLOTS to find the keyslot for foo manually?
In all our projects we use tabs, can I change this project too? (this is BIG commit :) )
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.