Using Redis pub / sub to invalidate cache entries

I have an ASP.NET web application that uses Redis (via the absolutely awesome StackExchange.Redis ) as its cache repository.

I also use Redis pub / sub to invalidate these cache entries when they should be updated (read: cache long, update as needed). However, I noticed that if the publishers wrote too fast, the web application (subscriber) could not keep up with the messages, and the connection to Redis through the socket was blocked and the reading did not end (note: this cannot be the reason for the socket that was blocked, but I made this conclusion after removing pub / sub from my web application, and the problem disappeared)

Note: I left the default value for the PreserveAsyncOrder parameter (true), but I think I could make it false because I don't care about the order of the messages?

To give you an idea of ​​how all this works, when you start (only once) a web application:

  • Creates a connection to Redis (one ConnectionMultiplexer)
  • Subscribe to a bunch of events

Then the background components publish messages to Redis (say, no more than 1 or 2 per second), which forces the web application to update (rather than delete) the cached record, for example, add an element to a previously existing set.

My questions:

  • Am I using Redis Pub / Sub incorrectly here? (Should I use queues, for example? Or is the items just expiring simply?)
  • SubscribeAsync -, , -, , ?
  • - StackExchange.Redis pub/sub - ASP.NET? ( - )

.

!

+4

All Articles