node-redis

Running multiple instance of Redis on Centos

拈花ヽ惹草 提交于 2019-12-04 22:00:57
问题 I want to run multiple instance of Redis on Centos 7. Can anyone point me to proper link or post steps here. I googled for the information but I didn't find any relevant information. 回答1: You can run multiple instances of Redis using different ports on a single machine. If this what concerns you then you can follow the below steps. By installing the first Redis instance, it listens on localhost:6379 by default. For Second Instance create a new working directory The default Redis instance uses

Connection to Redis cluster failed

本小妞迷上赌 提交于 2019-12-04 15:43:29
I have setup Redis cluster in Google compute Engine by click to deploy option. Now i want to connect to this redis server from my node js code using 'ioredis' here is my code to connect to single instance of redis var Redis = require("ioredis"); var store = new Redis(6379, 'redis-ob0g');//to store the keys var pub = new Redis(6379, 'redis-ob0g');//to publish a message to all workers var sub = new Redis(6379, 'redis-ob0g');//to subscribe a message var onError = function (err) { console.log('fail to connect to redis ',err); }; store.on('error',onError); pub.on('error',onError); sub.on('error'

Redis connection gone from close event

微笑、不失礼 提交于 2019-12-04 07:45:18
In our redis configuration we have set timeout: 7 seconds In node_redis We handle redis connection ready and end event as client.on("ready", function() { logger.info("Connection Successfully Established to ", this.host, this.port); } client.on("end", function() { logger.fatal("Connection Terminated to ", this.host, this.port); } Sample log [2012-07-11 08:21:29.545] [FATAL] Production - Connection Terminated on end to 'x.x.x.9' '6399' [2012-07-11 08:21:29.803] [INFO] Production - Connection Successfully Established to 'x.x.x.9' '6399' But in some cases (most probably redis is closing the

How can I run redis on a single server on different ports?

喜欢而已 提交于 2019-12-03 16:19:12
I'm using kue which uses node_redis , but I'm also already using node_redis for my sessions, so I'd like to have kue create a server on a specific port say the default 6379 and then kue listen on port 1234 . How would I be able to do this? I found this article which talks about something similar, but I don't really want to have to create an init script to do this. Launch redis-server and supply a different argument for 'port' which can be done on the command-line: edd@max:~$ redis-server -h Usage: ./redis-server [/path/to/redis.conf] [options] ./redis-server - (read config from stdin) ./redis

Running multiple instance of Redis on Centos

白昼怎懂夜的黑 提交于 2019-12-03 13:23:43
I want to run multiple instance of Redis on Centos 7. Can anyone point me to proper link or post steps here. I googled for the information but I didn't find any relevant information. Selva Kumar You can run multiple instances of Redis using different ports on a single machine. If this what concerns you then you can follow the below steps. By installing the first Redis instance, it listens on localhost:6379 by default. For Second Instance create a new working directory The default Redis instance uses /var/lib/redis as its working directory, dumped memory content is saved under this directory

count of keys matching a pattern

感情迁移 提交于 2019-12-03 06:28:08
问题 How can I find the count of all the keys that has a matching pattern. For example, there are two keys abc:random-text-1 and abc:random-text-2 . The common pattern here is abc: . So, here the count is 2. How can I do this in redis? 回答1: DISCLAIMER I hope this old answer haven't damaged any production systems, with millions of keys. If you still want to still count the matching keys of redis in production for some reason, better use scan with a match pattern. If you simply search with KEYS,

How to store a binary object in redis using node?

我是研究僧i 提交于 2019-12-03 01:39:53
I am trying to save a binary object in redis and then serve it back as an image. Here is the code I am using to save the data: var buff=new Buffer(data.data,'base64'); client.set(key,new Buffer(data.data,'base64')); Here is the code to dump the data out: client.get(key,function(err,reply){ var data = reply; response.writeHead(200, {"Content-Type": "image/png"}); response.end(data,'binary'); }); The first few byte of the data seem to be corrupted. The magic number is incorrect. Did some experimenting: when I do the following: var buff=new Buffer(data.data,'base64'); console.log(buff.toString(

count of keys matching a pattern

对着背影说爱祢 提交于 2019-12-02 19:56:01
How can I find the count of all the keys that has a matching pattern. For example, there are two keys abc:random-text-1 and abc:random-text-2 . The common pattern here is abc: . So, here the count is 2. How can I do this in redis? DISCLAIMER I hope this old answer haven't damaged any production systems, with millions of keys. If you still want to still count the matching keys of redis in production for some reason, better use scan with a match pattern . If you simply search with KEYS, with your redis client, you will get a number list of all you matching keys, right? e.g. KEYS abc:* will give

How to fix a race condition in node js + redis + mongodb web application

一曲冷凌霜 提交于 2019-12-02 11:03:36
I am building a web application that will process many transactions a second. I am using an Express Server with Node Js. On the database side, I am using Redis to store attributes of a user which will fluctuate continuously based on stock prices. I am using MongoDB to store semi-permanent attributes like Order configuration, User configuration, etc., I am hitting a race condition when multiple orders placed by a user are being processed at the same time, but only one would have been eligible as a check on the Redis attribute which stores the margin would not have allowed both the transactions.

How to store array of objects in Redis?

拟墨画扇 提交于 2019-12-01 19:45:12
I have an array of Objects that I want to store in Redis. I can break up the array part and store them as objects but I am not getting how I can get somethings like {0} : {"foo" :"bar", "qux" : "doe"}, {1} : {"name" "Saras", "age" : 23} and then search the db based on name and get the requested key back. I need something like this. but can't come close to getting it right. incr id //correct (integer) 3 get id //correct "3" SADD id {"name" : "Saras"} //wrong SADD myset {"name" : "Saras"} //correct (integer) 1 First is getting this part right. Second is somehow getting the key from the value i.e