Reputation: 100486
Using Redis pub/sub, is there a way to limit the number of listeners that Redis will publish to?
http://redis.io/commands/publish
For example, using Node.js parlance:
var redis = require('redis');
var rcPub = redis.createClient();
var rcSub = redis.createClient();
rcPub.publish('channel','messageA',{limit:1}); //desired functionality/syntax
basically, when I send messageA to Redis, I want to tell Redis to publish the message to only one listener/subscriber. Seems possible, but can Redis do this?
In the Redis docs, the command is:
PUBLISH channel message
what I am looking for is:
PUBLISH channel message limit
where limit is an integer. Seems reasonable, and easy to implement from Redis' perspective.
Upvotes: 2
Views: 1361
Reputation: 10015
You can add a channel per subscribed, and then publish to a single user's channel when you need to communicate with him.
Upvotes: 2