I have a service that has a bunch of incoming Orders that I store into an IReliableDictionary. As new orders come in, I need to update and maintain a separate sorted list of those orders throughout the lifetime of my program.
How do I efficiently and concurrency pivot the data in the IReliableDictionary into a different sorted collection such that I avoid deadlocks and don't have to rebuild the sorted list from scratch every time a new order comes in?
EDIT: After looking at the documentation I believe I can achieve this by updating my local memory sorted collection after an update before a commit.
using (var tx = this.StateManager.CreateTransaction())
{
bool addOk = await orderDictionary.TryAddAsync(tx, 123, someOrderToAdd);
if (addOk)
{
this.SortedOrders.Add(someOrderToAdd);
}
await tx.CommitAsync();
}
Can someone confirm that my understanding of the documentation is correct, and that something like the above implementation will not cause concurrency issues?