Skip to content

Commit

Permalink
Properly translate null etags
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikdevloed committed Sep 23, 2024
1 parent 2d21b3f commit 2c7617c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Redis/Orleans.Persistence.Redis/Storage/RedisGrainStorage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
Expand Down Expand Up @@ -225,7 +225,6 @@ public async Task ClearStateAsync<T>(string grainType, GrainId grainId, IGrainSt
{
try
{
RedisValue etag = grainState.ETag ?? "";
RedisResult response;
string newETag;
var key = _getKeyFunc(grainType, grainId);
Expand All @@ -241,7 +240,8 @@ public async Task ClearStateAsync<T>(string grainType, GrainId grainId, IGrainSt
return -1
end
""";
response = await _db.ScriptEvaluateAsync(DeleteScript, keys: new[] { key }, values: new[] { etag }).ConfigureAwait(false);
RedisValue[] values = grainState.ETag is null ? [] : [grainState.ETag];
response = await _db.ScriptEvaluateAsync(DeleteScript, keys: [key], values: values).ConfigureAwait(false);
newETag = null;
}
else
Expand All @@ -257,7 +257,8 @@ public async Task ClearStateAsync<T>(string grainType, GrainId grainId, IGrainSt
end
""";
newETag = Guid.NewGuid().ToString("N");
response = await _db.ScriptEvaluateAsync(ClearScript, keys: new[] { key }, values: new RedisValue[] { etag, newETag }).ConfigureAwait(false);
RedisValue[] values = grainState.ETag is null ? [] : [grainState.ETag, newETag];
response = await _db.ScriptEvaluateAsync(ClearScript, keys: [key], values: values).ConfigureAwait(false);
}

if (response is not null && (int)response == -1)
Expand All @@ -282,4 +283,4 @@ private async Task Close(CancellationToken cancellationToken)
_connection.Dispose();
}
}
}
}

0 comments on commit 2c7617c

Please sign in to comment.