コード例 #1
0
        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);
            }
        }
コード例 #2
0
        public virtual bool Remove(TKey key)
        {
            var status = _localCache.Remove(key);

            if (!status)
            {
                status = _persistantDictionary.Remove(key);
            }
            return(status);
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
 public override void Remove(string cacheType, string cacheKey)
 {
     _dictCache.Remove(GetCacheKey(cacheType, cacheKey));
 }