Search code examples
azure-service-fabric

IReliableDictionary 2 vs IReliableDictionary


Can anyone explain why service fabric has both IReliableDictionary and IReliableDictionary2 where IReliableDictionary DERIVES from IReliableDictionary2? It makes no sense and the documentation doesn't appear to explain it. Which one are you supposed to use?

https://learn.microsoft.com/en-us/dotnet/api/microsoft.servicefabric.data.collections.ireliabledictionary-2?view=azure-dotnet

Proof: enter image description here


Solution

  • IReliableDictionary2 has an additional property Count which is persisted alongside the collection's entries. This allows quick access to the number of entries in the collection, as usually you'd have to enumerate over its entries and calculate the count.

    This is not very clear from the API documentation, merely seeing "Oh this has an extra count property" does not, to me, alert that "You should use this if you need to readily access the count". Perhaps you could open an issue here explaining how it's not clear, or edit it and create a PR!