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
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@

namespace BitFaster.Caching.UnitTests.Lru
{
public class AfterAccessLongTicksPolicyTests
public class AfterAccessPolicyTests
{
private readonly AfterAccessLongTicksPolicy<int, int> policy = new AfterAccessLongTicksPolicy<int, int>(TimeSpan.FromSeconds(10));
private readonly AfterAccessPolicy<int, int> policy = new AfterAccessPolicy<int, int>(TimeSpan.FromSeconds(10));

[Fact]
public void WhenTtlIsTimeSpanMaxThrow()
{
Action constructor = () => { new AfterAccessLongTicksPolicy<int, int>(TimeSpan.MaxValue); };
Action constructor = () => { new AfterAccessPolicy<int, int>(TimeSpan.MaxValue); };

constructor.Should().Throw<ArgumentOutOfRangeException>();
}

[Fact]
public void WhenTtlIsZeroThrow()
{
Action constructor = () => { new AfterAccessLongTicksPolicy<int, int>(TimeSpan.Zero); };
Action constructor = () => { new AfterAccessPolicy<int, int>(TimeSpan.Zero); };

constructor.Should().Throw<ArgumentOutOfRangeException>();
}
Expand All @@ -38,7 +38,7 @@ public void WhenTtlIsMaxSetAsMax()
#else
var maxRepresentable = Time.MaxRepresentable;
#endif
var policy = new AfterAccessLongTicksPolicy<int, int>(maxRepresentable);
var policy = new AfterAccessPolicy<int, int>(maxRepresentable);
policy.TimeToLive.Should().BeCloseTo(maxRepresentable, TimeSpan.FromTicks(20));
}

Expand Down
1 change: 0 additions & 1 deletion BitFaster.Caching.UnitTests/Lru/DiscretePolicyTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using BitFaster.Caching.Lru;
using FluentAssertions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace BitFaster.Caching.Lru
/// <summary>
/// Implement an expire after access policy.
/// </summary>
internal readonly struct AfterAccessLongTicksPolicy<K, V> : IItemPolicy<K, V, LongTickCountLruItem<K, V>>
internal readonly struct AfterAccessPolicy<K, V> : IItemPolicy<K, V, LongTickCountLruItem<K, V>>
{
private readonly Duration timeToLive;
private readonly Time time;
Expand All @@ -18,7 +18,7 @@ namespace BitFaster.Caching.Lru
/// Initializes a new instance of the AfterReadTickCount64Policy class with the specified time to live.
/// </summary>
/// <param name="timeToLive">The time to live.</param>
public AfterAccessLongTicksPolicy(TimeSpan timeToLive)
public AfterAccessPolicy(TimeSpan timeToLive)
{
if (timeToLive <= TimeSpan.Zero || timeToLive > Time.MaxRepresentable)
Throw.ArgOutOfRange(nameof(timeToLive), $"Value must greater than zero and less than {Time.MaxRepresentable}");
Expand Down
4 changes: 2 additions & 2 deletions BitFaster.Caching/Lru/ConcurrentLru.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ internal static ICache<K, V> Create<K, V>(LruInfo<K> info)

private static ICache<K, V> CreateExpireAfterAccess<K, V, TP>(LruInfo<K> info) where TP : struct, ITelemetryPolicy<K, V>
{
return new ConcurrentLruCore<K, V, LongTickCountLruItem<K, V>, AfterAccessLongTicksPolicy<K, V>, TP>(
info.ConcurrencyLevel, info.Capacity, info.KeyComparer, new AfterAccessLongTicksPolicy<K, V>(info.TimeToExpireAfterAccess.Value), default);
return new ConcurrentLruCore<K, V, LongTickCountLruItem<K, V>, AfterAccessPolicy<K, V>, TP>(
info.ConcurrencyLevel, info.Capacity, info.KeyComparer, new AfterAccessPolicy<K, V>(info.TimeToExpireAfterAccess.Value), default);
}

private static ICache<K, V> CreateExpireAfter<K, V, TP>(LruInfo<K> info, IExpiryCalculator<K, V> expiry) where TP : struct, ITelemetryPolicy<K, V>
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching/Lru/ConcurrentLruCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ private static CachePolicy CreatePolicy(ConcurrentLruCore<K, V, I, P, T> lru)
{
var p = new Proxy(lru);

if (typeof(P) == typeof(AfterAccessLongTicksPolicy<K, V>))
if (typeof(P) == typeof(AfterAccessPolicy<K, V>))
{
return new CachePolicy(new Optional<IBoundedPolicy>(p), Optional<ITimePolicy>.None(), new Optional<ITimePolicy>(p), Optional<IDiscreteTimePolicy>.None());
}
Expand Down