From 9945c986d95758641b4843f4c0e8a9f9d7ef3ef0 Mon Sep 17 00:00:00 2001 From: ta264 Date: Sun, 27 Sep 2020 15:50:15 +0100 Subject: [PATCH] Revert Cached changes from bb02d73c4 Bring it back in line with Sonarr. I was originally worried that we were caching all Artists and this would be a resource hog. But the caching will happen on every RSS scan so I think we're better off just holding the cache and not worrying. --- .../CacheTests/CachedFixture.cs | 27 ------------------- src/NzbDrone.Common/Cache/Cached.cs | 5 ---- 2 files changed, 32 deletions(-) diff --git a/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs b/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs index 9bb63c7e7..cf3de2d3b 100644 --- a/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs +++ b/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs @@ -101,33 +101,6 @@ namespace NzbDrone.Common.Test.CacheTests hitCount.Should().BeInRange(3, 7); } - - [Test] - [Retry(3)] - [Platform(Exclude = "MacOsX")] - public void should_clear_expired_when_they_expire() - { - int hitCount = 0; - _cachedString = new Cached(); - - for (int i = 0; i < 10; i++) - { - _cachedString.Get("key", - () => - { - hitCount++; - return null; - }, - TimeSpan.FromMilliseconds(300)); - - Thread.Sleep(100); - } - - Thread.Sleep(1000); - - hitCount.Should().BeInRange(3, 7); - _cachedString.Values.Should().HaveCount(0); - } } public class Worker diff --git a/src/NzbDrone.Common/Cache/Cached.cs b/src/NzbDrone.Common/Cache/Cached.cs index 8c953190e..2285f548d 100644 --- a/src/NzbDrone.Common/Cache/Cached.cs +++ b/src/NzbDrone.Common/Cache/Cached.cs @@ -39,11 +39,6 @@ namespace NzbDrone.Common.Cache { Ensure.That(key, () => key).IsNotNullOrWhiteSpace(); _store[key] = new CacheItem(value, lifetime); - - if (lifetime != null) - { - System.Threading.Tasks.Task.Delay(lifetime.Value).ContinueWith(t => _store.TryRemove(key, out var temp)); - } } public T Find(string key)