Best way to handle multiple change streams with SignalR

102 views Asked by At

I have a .NET Core application that using MongoDB with change streams to retrieve database modifications. Depending on the retrieved documents, a MongoDB query is executed to count the number of documents per client based on their status. The query result is stored in the cache (IMemoryCache) so that upon the next database modification, I can retrieve the cached result and update it based on the modifications from the next document. I use the cache to avoid pooling database all the time.

A message containing the number of documents per client and status is sent using SignalR. An Angular application connected to the hub receives the message and displays it in a grid.

It’s working, but I'm wondering if there's a simpler method to implement than using the cache. Could you provide any advice on whether using the cache is a good solution or if there's a more straightforward approach?

Thank you for your guidance.

0

There are 0 answers