Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ dotnet_diagnostic.CA1056.severity = none
# Validate arguments of public methods
dotnet_diagnostic.CA1062.severity = none

# CancellationToken parameters must come last
dotnet_diagnostic.CA1068.severity = error

# Do not pass literals as localized parameters
dotnet_diagnostic.CA1303.severity = suggestion

Expand Down
4 changes: 2 additions & 2 deletions src/UiPath.Caching/MultilayerCacheBase.LayeredEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public ValueTask<bool> PublishSetAsync(TOptions options, VersionedWrite counted
}

/// <summary>A source that ends with <paramref name="ct"/> or after <paramref name="budget"/>; <paramref name="timeout"/> is the budget's own source, set only when the clock is not the system one.</summary>
private static CancellationTokenSource LinkReadBudget(TimeProvider clock, CancellationToken ct, TimeSpan budget, out CancellationTokenSource? timeout)
private static CancellationTokenSource LinkReadBudget(TimeProvider clock, TimeSpan budget, CancellationToken ct, out CancellationTokenSource? timeout)
{
if (ReferenceEquals(clock, TimeProvider.System))
{
Expand Down Expand Up @@ -266,7 +266,7 @@ private async ValueTask<bool> TryAdoptInnerAsync(CacheKey originalCacheKey, Date
var rehydrate = policy.Rehydrate!;
var options = shape.BuildOptions(originalCacheKey, entryExpiration, ct);
var budget = RehydrationCoordinator.AdoptReadTimeout(rehydrate, duration);
var read = LinkReadBudget(cache._clock, ct, budget, out var timeout);
var read = LinkReadBudget(cache._clock, budget, ct, out var timeout);
using var timeoutScope = timeout;
using var readScope = read;
var mark = cache.MarkInnerRead(options.CacheKey.Name, options.TopicKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,9 @@ public async Task A_hash_move_reports_the_source_ttl_and_its_request_time()
var result = await Target(kit).MoveAsync("k", TimeSpan.Zero, kit.Kit.Id, AlwaysOwned.Instance, (ttl, at) => seen.Add((ttl, at)), Ct);

result.Moved.Should().BeTrue();
var observed = seen.Should().ContainSingle().Subject;
observed.At.Should().Be(Start.ToUnixTimeMilliseconds());
observed.Ttl.Should().BeInRange(1, (long)TimeSpan.FromMinutes(5).TotalMilliseconds);
var (ttl, at) = seen.Should().ContainSingle().Subject;
at.Should().Be(Start.ToUnixTimeMilliseconds());
ttl.Should().BeInRange(1, (long)TimeSpan.FromMinutes(5).TotalMilliseconds);
}

[Theory]
Expand Down
9 changes: 5 additions & 4 deletions tests/UiPath.Caching.Tests/KeyMove/RedisSignals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ public static async Task<ExpirySubscription> ObserveExpiryAsync(IConnectionMulti
var subscriber = admin.GetSubscriber();
var channel = RedisChannel.Literal("__keyevent@0__:expired");
var expired = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
Action<RedisChannel, RedisValue> handler = (_, value) =>
void OnExpired(RedisChannel _, RedisValue value)
{
if (value == key.ToString())
{
expired.TrySetResult();
}
};
await subscriber.SubscribeAsync(channel, handler);
return new ExpirySubscription(admin, server, subscriber, channel, handler, before, expired.Task);
}

await subscriber.SubscribeAsync(channel, OnExpired);
return new ExpirySubscription(admin, server, subscriber, channel, OnExpired, before, expired.Task);
}

internal sealed class ExpirySubscription(ConnectionMultiplexer admin, IServer server, ISubscriber subscriber, RedisChannel channel, Action<RedisChannel, RedisValue> handler, string before, Task expired) : IAsyncDisposable
Expand Down