Slicc
Slicc

Reputation: 3445

Has the contents of an IReliableDictionary changed?

I am periodically doing full backups of an IReliableDictionary is Azure Service Fabric. Every X minutes I check to see if the number of elements in the collection has changed and if so, I create a new backup.

This obviously has the downside that if I just change the value of an item in the dictionary, the collection size does not change and no backup occurs.

One solution would be to enumerate the entire dictionary and calculate an overall hash for the collection (assuming the order of the items can be guaranteed). Is there a better way to identify if an IReliableDictionary has changed?

Upvotes: 1

Views: 64

Answers (1)

LoekD
LoekD

Reputation: 11470

There are a few events generated by the StateManager that may be helpful.

TransactionChanged events are raised if the transaction is committed.

For example:

public MyService(StatefulServiceContext context)
    : base(MyService.EndpointName, context, CreateReliableStateManager(context))
{
    this.StateManager.TransactionChanged += this.OnTransactionChangedHandler;
}

Upvotes: 2

Related Questions