public async void ClearKey_CallsCacheProvider() { var cache = new SimpleCache <string>(_cacheProviderFactoryMock.Object); await cache.Clear("foo"); _cacheProviderMock.Verify(_ => _.RemoveAsync(It.IsAny <string>()), Times.Once()); }
public void TestCountAndClear() { Assert.AreEqual(0, cache.Count); int testCount = 4; for (int i = 0; i < testCount; i++) { cache.Set($"key{i}", $"value{i}"); } Assert.AreEqual(testCount, cache.Count); cache.Clear(); Assert.AreEqual(0L, cache.Count); }
public void Clear() { var cache = new SimpleCache <int, IntHolder>(10, i => new IntHolder { Int = i }); var a = cache.Get(1); var b = cache.Get(2); Assert.Equal(a, cache.Get(1)); Assert.Equal(b, cache.Get(2)); cache.Clear(); Assert.NotEqual(a, cache.Get(1)); Assert.NotEqual(b, cache.Get(2)); }
public void Clearing_cache_should_work_as_expected() { /* Arrange */ var c = new SimpleCache<string, string>(); /* Act */ c.Add("Val1", "TheValue", 10000, false); c.Add("Val2", "TheValue2", 10000, false); int countPre = c.Count; c.Clear(); int countPost = c.Count; /* Assert */ countPre.Should().Be(2); countPost.Should().Be(0); }
private static bool RebuildCache() { lock ( ByType ) { //if ( Repo == null ) { CreateCache(); return false; } var count = AllDefs.Count; if (count <= ByType[typeof(BaseDef)].Count) { return(false); } Verbo("Cache miss; rebuilding BaseDef cache."); foreach (var list in ByType.Values) { list.Clear(); } ByName.Clear(); ByPath.Clear(); CreateCache(); return(true); } }
public void Clear() { _localData.Clear(); }