SignalR/SignalR — pull request #3094 by Xiaohongt (2014-06-20 05:12:21+00:00)
Title: Restore the latest value to Redis Key on ConnectionRestored event

For Redis restart scenario, since Redis is in-memory key-value data store, it only saves the data to disk periodically, after Redis restart, it actually will get old data from disk instead of the latest data most of the times.

In this case, so far SignalR Redis scale-out just get the old data for message.Id after Redis restart, then for the existing connections ( which started before Redis server restarted) the new cursor doesn’t match and the connections miss the messages until the message.Id match to the “latest” data which is before Redis restart, e.g.
Let’s say, SignalR Redis scale-out uses Key “SignalRSamples” for eventKey, before the Redis restart, the Key “SignalRSamples” latest value was "7799425", after the Redis restart, the Key “SignalRSamples” value become "7799200", then the existing connection will miss 225 messages until the Key “SignalRSamples” value increases to "7799425”.

To avoid missing messages in the existing connections in this case, here are changes :
1). Save the latest value for the eventKey in RedisConnection
2). When Redis restart, in ConnectionRestored event set /restore the latest value to the eventKey in Redis

Verified:
1). With the change, the existing connections will not miss message
2). Works for 2 web apps using the Redis scale-out
3). Existing tests and new tests passed

#3091