-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
I'm playing around with Orleans and found your repository, because I was looking into managing Identities with Orleans.
I stumble across ILookupGrain.AddOrUpdate. It will never update a value, once it's in the dictionary.
If this is on purpose, shouldn't it be name just Add?
Otherwise, it should maybe do something like:
diff --git a/src/Orleans.IdentityStore/Grains/LookupGrain.cs b/src/Orleans.IdentityStore/Grains/LookupGrain.cs
index 1ef3f77..b094bb8 100644
--- a/src/Orleans.IdentityStore/Grains/LookupGrain.cs
+++ b/src/Orleans.IdentityStore/Grains/LookupGrain.cs
@@ -34,11 +34,11 @@ namespace Orleans.IdentityStore.Grains
public async Task<bool> AddOrUpdate(string value, Guid grainKey)
{
- if (_index.State.Index.ContainsKey(value))
- return false;
-
- _index.State.Index[value] = grainKey;
- await _index.WriteStateAsync();
+ if (!_index.State.Index.TryGetValue(value, out var oldGrainKey) || grainKey != oldGrainKey)
+ {
+ _index.State.Index[value] = grainKey;
+ await _index.WriteStateAsync();
+ }
return true;
}
Thank you!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels