node-redis is a complete Redis client for node.js. It supports all Redis commands, including many recently added commands like EVAL from experimental Redis server branches.
Questions tagged [node-redis]
756 questions
99
votes
5 answers
How to count the number of keys matching a pattern?
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 isabc: . So, here the count is 2.
How can I do this in redis?

shanks
- 1,847
- 2
- 15
- 17
72
votes
4 answers
Scaling Socket.IO to multiple Node.js processes using cluster
Tearing my hair out with this one... has anyone managed to scale Socket.IO to multiple "worker" processes spawned by Node.js's cluster module?
Lets say I have the following on four worker processes (pseudo):
// on the server
var express =…

Lee Benson
- 11,185
- 6
- 43
- 57
60
votes
7 answers
Node_redis - how to remove a key?
Is there any way to remove/delete an entry by key, using Node_redis? I can't see any such option from the docs..

UpTheCreek
- 31,444
- 34
- 152
- 221
49
votes
2 answers
How to delete everything in node redis?
I want to be able to delete all the keys. Is there a way to flush all in node redis?
Redis client:
client = redis.createClient(REDIS_PORT, REDIS_HOST);

Nelson
- 2,972
- 3
- 23
- 34
33
votes
8 answers
Redis NodeJs server error,client is closed
I am developing an application where chats has to cached and monitored, currently it is an local application where i have installed redis and redis-cli.
The problem i'm facing is (node:5368) UnhandledPromiseRejectionWarning: Error: The client is…

Makarand
- 477
- 1
- 7
- 17
33
votes
7 answers
How can I update a redis value without affecting the remaining TTL?
Is it possible to SET redis keys without removing their existing ttl? The only way I know of at the present time is to find out the ttl and do a SETEX but that seems less accurate.

paulkon
- 1,755
- 2
- 20
- 34
24
votes
7 answers
How to store a binary object in redis using node?
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…

SamFisher83
- 3,937
- 9
- 39
- 52
20
votes
3 answers
How to set expiration time for hmset in node redis?
I used to do client.setex(key, 900, value) for storing single key-value.
But, I want to store an object with expiration time.
I come up with function hmset, but I don't know how to make expiration time.
I want to use it to store the context and the…

Terry Djony
- 1,975
- 4
- 23
- 41
20
votes
2 answers
Node.js + Express + Redis, when to close connection?
I have a Node application that uses Express and node_redis. I'm following the approach outlined in the Learning Node book and creating a single client for the life of the application. Given this approach, when do I call close() on the redis client?…

Bart Jedrocha
- 11,450
- 5
- 43
- 53
18
votes
2 answers
Running multiple instance of Redis on Centos
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.

Ashish Sinha
- 194
- 1
- 1
- 10
18
votes
2 answers
Redis command to list all subscribers subscribed to redis channel
Below command only gives channel list .
127.0.0.1:6379> PUBSUB CHANNELS
1) "mychannel"
2) "mychanne2"
How to LIST subscribers subscribed on channel1 OR channel2 .?
also
i din't found redis command to list all subscribers Of a particular channel

Mr punch
- 1,756
- 4
- 16
- 23
16
votes
4 answers
Node-Redis: ready check failed - NOAUTH Authentication required
I have a strange redis behavior:
const redis = require('redis');
const { REDIS_URL: redisUrl, REDIS_PASSWORD: redisPassword } = process.env;
const client = redis.createClient(redisUrl, {
no_ready_check: true,
auth_pass:…

Enthusiastic Developer
- 692
- 1
- 8
- 23
16
votes
2 answers
Building a simple news feed in node + Mongodb + Redis
My goal is to build a simple news feed in node.js with the help of mongodb and redis. It similar like twitter
So the scenario is pretty straight forward, once User A follow User B. Later on User's A News feed (Home page) will be shown User B's…

sinusGob
- 4,053
- 12
- 46
- 82
16
votes
2 answers
How to remove element from list in Redis by value?
How to remove element from list in Redis by value?
For exmaple, I have:
127.0.0.1:6379> lrange POST:544 0 -1
1) "1"
2) "2"
3) "36"
127.0.0.1:6379>
I know only value 36, not index. Can I remove element from list by value?

Faud
- 451
- 3
- 7
- 16
16
votes
1 answer
How to use redis to store hierarchical data?
I have a set of hierarchical data to store, the hierarchy is like site/building/floor, the data, for example
{
site:'New York',
buildings: [
{
name:'building a',
floors: [
…

user824624
- 7,077
- 27
- 106
- 183