Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Here is another pull request for the pub/sub implementation. The new RedisSub extends from Redis and adds (p)(un)subscribe methods. Received messages are treated as C# events.
A new ReadMixedArray method has been added to receive arrays with elements of mixed data types and nested arrays -- subscribe messages contain an integer element. The new Redis Scan method has been added as a second use case for such mixed arrays (and because it is an important alternative to the KEYS command for large databases).
Note that Redis subscribers must not send regular Redis commands, in order to not mess up command replies with messages. This is also why the QUIT command has been commented out in Redis.Dispose(). One might consider to split the existing Redis class into a basic RedisClient that just treats the connection and the communication protocol -- comparable to the redis-cli program -- and a second Redis class that extends from RedisClient and provides all the C# methods for specific commands. RedisSub could then extend from the RedisClient as well and would not inherit commands that should not be used by subscribers. Redis.Dispose() could then call QUIT, while RedisClient.Dispose() would close the socket.