diff --git a/src/Redis/Orleans.Persistence.Redis/Storage/RedisGrainStorage.cs b/src/Redis/Orleans.Persistence.Redis/Storage/RedisGrainStorage.cs index ae3fd3c3b2..b22e0830e3 100644 --- a/src/Redis/Orleans.Persistence.Redis/Storage/RedisGrainStorage.cs +++ b/src/Redis/Orleans.Persistence.Redis/Storage/RedisGrainStorage.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics; using System.Globalization; using System.Linq; @@ -225,7 +225,6 @@ public async Task ClearStateAsync(string grainType, GrainId grainId, IGrainSt { try { - RedisValue etag = grainState.ETag ?? ""; RedisResult response; string newETag; var key = _getKeyFunc(grainType, grainId); @@ -241,7 +240,8 @@ public async Task ClearStateAsync(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 @@ -257,7 +257,8 @@ public async Task ClearStateAsync(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) @@ -282,4 +283,4 @@ private async Task Close(CancellationToken cancellationToken) _connection.Dispose(); } } -} \ No newline at end of file +}