Alexander Mills
Alexander Mills

Reputation: 100320

Redis pub/sub design issue

I have a Redis client like so:

var redis = require("redis");
var client = redis.createClient();
client.config("SET","notify-keyspace-events", "KEA");

with the 3rd line of code, it is now configured to listen to sets and deletes of Redis keys. So this client acts as a subscriber. However, the problem is that I want this Redis client to also be able to re-publish information it receives from Redis itself, and the same Redis client can't act as both subscriber and publisher. So it seems I have two choices:

  1. use a second Redis client in the same file, to act as a publisher
  2. use Socket.io with only one Redis client instead of two

Is this correct? Which one is better in this case?

Upvotes: 1

Views: 109

Answers (1)

Didier Spezia
Didier Spezia

Reputation: 73306

No need of Socket.IO there. Just use a second Redis client. An extra Redis connection is cheap.

Upvotes: 2

Related Questions