public async Task Should_add_item_to_cache_when_context_exists() { using (sut.StartContext()) { sut.Add("Key", 1); await Task.Delay(5); AssertCache(sut, "Key", 1, true); await Task.Delay(5); sut.Remove("Key"); AssertCache(sut, "Key", null, false); } }
public virtual bool Remove(TKey key) { var status = _localCache.Remove(key); if (!status) { status = _persistantDictionary.Remove(key); } return(status); }
public async Task Should_add_item_to_cache_when_context_exists() { using (sut.StartContext()) { sut.Add("Key", 1); await Task.Delay(5); var found = sut.TryGetValue("Key", out var value); Assert.True(found); Assert.Equal(1, value); await Task.Delay(5); sut.Remove("Key"); var foundAfterRemove = sut.TryGetValue("Key", out value); Assert.False(foundAfterRemove); Assert.Null(value); } }
public override void Remove(string cacheType, string cacheKey) { _dictCache.Remove(GetCacheKey(cacheType, cacheKey)); }