From 6ccff44c86cbb77740fabd4c14ff76206c960974 Mon Sep 17 00:00:00 2001 From: Alex Peck Date: Sat, 23 Jul 2022 19:57:37 -0700 Subject: [PATCH] rem dep props --- .../Lru/ConcurrentLruTests.cs | 39 ------------------- .../Lru/ConcurrentTLruTests.cs | 39 ------------------- BitFaster.Caching/Lru/ConcurrentLru.cs | 16 -------- BitFaster.Caching/Lru/ConcurrentTLru.cs | 16 -------- 4 files changed, 110 deletions(-) diff --git a/BitFaster.Caching.UnitTests/Lru/ConcurrentLruTests.cs b/BitFaster.Caching.UnitTests/Lru/ConcurrentLruTests.cs index 7830ded5..9cb2595e 100644 --- a/BitFaster.Caching.UnitTests/Lru/ConcurrentLruTests.cs +++ b/BitFaster.Caching.UnitTests/Lru/ConcurrentLruTests.cs @@ -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() { @@ -505,34 +494,6 @@ public void WhenValueExpiresItIsDisposed() disposableValueFactory.Items[6].IsDisposed.Should().BeFalse(); } - [Fact] - public void WhenValueEvictedItemRemovedDeprecatedEventIsFired() - { - var lruEvents = new ConcurrentLru(1, new EqualCapacityPartition(6), EqualityComparer.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() diff --git a/BitFaster.Caching.UnitTests/Lru/ConcurrentTLruTests.cs b/BitFaster.Caching.UnitTests/Lru/ConcurrentTLruTests.cs index de8028e7..2d83a232 100644 --- a/BitFaster.Caching.UnitTests/Lru/ConcurrentTLruTests.cs +++ b/BitFaster.Caching.UnitTests/Lru/ConcurrentTLruTests.cs @@ -82,34 +82,6 @@ public async Task WhenItemIsUpdatedTtlIsExtended() lru.TryGet(1, out var value).Should().BeTrue(); } - [Fact] - public void WhenValueEvictedItemRemovedDeprecatedEventIsFired() - { - var lruEvents = new ConcurrentTLru(1, new EqualCapacityPartition(6), EqualityComparer.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() { @@ -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() { diff --git a/BitFaster.Caching/Lru/ConcurrentLru.cs b/BitFaster.Caching/Lru/ConcurrentLru.cs index c22c7a01..53741295 100644 --- a/BitFaster.Caching/Lru/ConcurrentLru.cs +++ b/BitFaster.Caching/Lru/ConcurrentLru.cs @@ -42,21 +42,5 @@ public ConcurrentLru(int concurrencyLevel, ICapacityPartition capacity, IEqualit : base(concurrencyLevel, capacity, comparer, default, default) { } - - /// - /// Gets the ratio of hits to misses, where a value of 1 indicates 100% hits. - /// - [ObsoleteAttribute("This property is obsolete. Use Metrics instead.", false)] - public double HitRatio => this.telemetryPolicy.HitRatio; - - /// - /// Occurs when an item is removed from the cache. - /// - [ObsoleteAttribute("This property is obsolete. Use Events instead.", false)] - public event EventHandler> ItemRemoved - { - add { this.Events.ItemRemoved += value; } - remove { this.Events.ItemRemoved -= value; } - } } } diff --git a/BitFaster.Caching/Lru/ConcurrentTLru.cs b/BitFaster.Caching/Lru/ConcurrentTLru.cs index 1dbfd34b..dbb21e4a 100644 --- a/BitFaster.Caching/Lru/ConcurrentTLru.cs +++ b/BitFaster.Caching/Lru/ConcurrentTLru.cs @@ -46,22 +46,6 @@ public ConcurrentTLru(int concurrencyLevel, ICapacityPartition capacity, IEquali { } - /// - /// Gets the ratio of hits to misses, where a value of 1 indicates 100% hits. - /// - [ObsoleteAttribute("This property is obsolete. Use Metrics instead.", false)] - public double HitRatio => this.telemetryPolicy.HitRatio; - - /// - /// Occurs when an item is removed from the cache. - /// - [ObsoleteAttribute("This property is obsolete. Use Events instead.", false)] - public event EventHandler> ItemRemoved - { - add { this.Events.ItemRemoved += value; } - remove { this.Events.ItemRemoved -= value; } - } - /// /// Remove all expired items from the cache. ///