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
39 changes: 0 additions & 39 deletions BitFaster.Caching.UnitTests/Lru/ConcurrentLruTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,6 @@ public void WhenItemDoesNotExistTryGetReturnsNullAndFalse()
value.Should().BeNull();
}

[Fact]
public void WhenItemIsAddedThenRetrievedHitRatioIsHalf()
{
lru.GetOrAdd(1, valueFactory.Create);
bool result = lru.TryGet(1, out var value);

#pragma warning disable CS0618 // Type or member is obsolete
lru.HitRatio.Should().Be(0.5);
#pragma warning restore CS0618 // Type or member is obsolete
}

[Fact]
public void MetricsAreEnabled()
{
Expand Down Expand Up @@ -505,34 +494,6 @@ public void WhenValueExpiresItIsDisposed()
disposableValueFactory.Items[6].IsDisposed.Should().BeFalse();
}

[Fact]
public void WhenValueEvictedItemRemovedDeprecatedEventIsFired()
{
var lruEvents = new ConcurrentLru<int, int>(1, new EqualCapacityPartition(6), EqualityComparer<int>.Default);
#pragma warning disable CS0618 // Type or member is obsolete
lruEvents.ItemRemoved += OnLruItemRemoved;
#pragma warning restore CS0618 // Type or member is obsolete

// First 6 adds
// hot[6, 5], warm[2, 1], cold[4, 3]
// =>
// hot[8, 7], warm[1, 0], cold[6, 5], evicted[4, 3]
for (int i = 0; i < 8; i++)
{
lruEvents.GetOrAdd(i + 1, i => i + 1);
}

removedItems.Count.Should().Be(2);

removedItems[0].Key.Should().Be(3);
removedItems[0].Value.Should().Be(4);
removedItems[0].Reason.Should().Be(ItemRemovedReason.Evicted);

removedItems[1].Key.Should().Be(4);
removedItems[1].Value.Should().Be(5);
removedItems[1].Reason.Should().Be(ItemRemovedReason.Evicted);
}


[Fact]
public void WhenValueEvictedItemRemovedEventIsFired()
Expand Down
39 changes: 0 additions & 39 deletions BitFaster.Caching.UnitTests/Lru/ConcurrentTLruTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,34 +82,6 @@ public async Task WhenItemIsUpdatedTtlIsExtended()
lru.TryGet(1, out var value).Should().BeTrue();
}

[Fact]
public void WhenValueEvictedItemRemovedDeprecatedEventIsFired()
{
var lruEvents = new ConcurrentTLru<int, int>(1, new EqualCapacityPartition(6), EqualityComparer<int>.Default, timeToLive);
#pragma warning disable CS0618 // Type or member is obsolete
lruEvents.ItemRemoved += OnLruItemRemoved;
#pragma warning restore CS0618 // Type or member is obsolete

// First 6 adds
// hot[6, 5], warm[2, 1], cold[4, 3]
// =>
// hot[8, 7], warm[1, 0], cold[6, 5], evicted[4, 3]
for (int i = 0; i < 8; i++)
{
lruEvents.GetOrAdd(i + 1, i => i + 1);
}

removedItems.Count.Should().Be(2);

removedItems[0].Key.Should().Be(3);
removedItems[0].Value.Should().Be(4);
removedItems[0].Reason.Should().Be(ItemRemovedReason.Evicted);

removedItems[1].Key.Should().Be(4);
removedItems[1].Value.Should().Be(5);
removedItems[1].Reason.Should().Be(ItemRemovedReason.Evicted);
}

[Fact]
public void WhenValueEvictedItemRemovedEventIsFired()
{
Expand Down Expand Up @@ -151,17 +123,6 @@ public void WhenItemRemovedEventIsUnregisteredEventIsNotFired()
removedItems.Count.Should().Be(0);
}

[Fact]
public void WhenItemIsAddedThenRetrievedHitRatioIsHalf()
{
lru.GetOrAdd(1, valueFactory.Create);
bool result = lru.TryGet(1, out var value);

#pragma warning disable CS0618 // Type or member is obsolete
lru.HitRatio.Should().Be(0.5);
#pragma warning restore CS0618 // Type or member is obsolete
}

[Fact]
public async Task WhenItemsAreExpiredExpireRemovesExpiredItems()
{
Expand Down
16 changes: 0 additions & 16 deletions BitFaster.Caching/Lru/ConcurrentLru.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,5 @@ public ConcurrentLru(int concurrencyLevel, ICapacityPartition capacity, IEqualit
: base(concurrencyLevel, capacity, comparer, default, default)
{
}

/// <summary>
/// Gets the ratio of hits to misses, where a value of 1 indicates 100% hits.
/// </summary>
[ObsoleteAttribute("This property is obsolete. Use Metrics instead.", false)]
public double HitRatio => this.telemetryPolicy.HitRatio;

/// <summary>
/// Occurs when an item is removed from the cache.
/// </summary>
[ObsoleteAttribute("This property is obsolete. Use Events instead.", false)]
public event EventHandler<ItemRemovedEventArgs<K, V>> ItemRemoved
{
add { this.Events.ItemRemoved += value; }
remove { this.Events.ItemRemoved -= value; }
}
}
}
16 changes: 0 additions & 16 deletions BitFaster.Caching/Lru/ConcurrentTLru.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,6 @@ public ConcurrentTLru(int concurrencyLevel, ICapacityPartition capacity, IEquali
{
}

/// <summary>
/// Gets the ratio of hits to misses, where a value of 1 indicates 100% hits.
/// </summary>
[ObsoleteAttribute("This property is obsolete. Use Metrics instead.", false)]
public double HitRatio => this.telemetryPolicy.HitRatio;

/// <summary>
/// Occurs when an item is removed from the cache.
/// </summary>
[ObsoleteAttribute("This property is obsolete. Use Events instead.", false)]
public event EventHandler<ItemRemovedEventArgs<K, V>> ItemRemoved
{
add { this.Events.ItemRemoved += value; }
remove { this.Events.ItemRemoved -= value; }
}

/// <summary>
/// Remove all expired items from the cache.
/// </summary>
Expand Down