Comment From: madolson
When checking to see if a client is listening to a channel, we can directly look for matches with a dictionary. With patterns though, we have to look up all of the patterns the server cares about, and evaluate each one. There is some area for optimization here, searching for patterns in a RAX perhaps, but we haven't done that optimization.
Comment From: ohye3166
When checking to see if a client is listening to a channel, we can directly look for matches with a dictionary. With patterns though, we have to look up all of the patterns the server cares about, and evaluate each one. There is some area for optimization here, searching for patterns in a RAX perhaps, but we haven't done that optimization.
in redis-cli structure,can pubsub_channels type change to list? because it's value always be null
Comment From: zuiderkwast
@ohye The code in your screenshot is the client struct defined in server.h. It is not used by redis-cli. It is used by Redis server to hold data related to a connected client.
The value of pubsub_channels is not null. It is initated whenever a client connects, in networking.c, function createClient:
c->watched_keys = listCreate();
c->pubsub_channels = dictCreate(&objectKeyPointerValueDictType);
c->pubsub_patterns = listCreate();