I have two roles, Doctors, and Patients...
When a Patient does action A, I want a broadcast to go out to a list of Doctors, not All of the Doctors, but a list of them..
In my testing, I was able to accomplish this by subscribing with redis in node to channels prefixed with Doctor and a hyphen then UserID...
redis.subscribe('Doctor-1', function(err, count) {
});
However, for production, I can not hardcode that ID, what I need is something like the following
redis.subscribe('Doctor-*', function(err, count) {
});
But the wildcard does not seem to work...
Any ideas on how I can subscribe to a wildcard ?
Redis.io, PubSub Documentation
The Redis Pub/Sub implementation supports pattern matching. Clients may subscribe to glob-style patterns in order to receive all the messages sent to channel names matching a given pattern.
For instance:
PSUBSCRIBE news.*
So your snippet could change to
redis.subscribe('Doctor.*', function(err, count) {});
So it will receive any for Doctor with ID Doctor.1
or more in depth
Doctors.<groupId>.<DoctorId>
and so on.