public async Task InMemoryCached_Will_Fetch_Or_Cache_Based_On_Key()
        {
            // Arrange, Act
            var result1 = await _inMemoryCached.GetOrFetchAsync(1);

            var result2 = await _inMemoryCached.GetOrFetchAsync(2);

            var result3 = await _inMemoryCached.GetOrFetchAsync(1);

            var result4 = await _inMemoryCached.GetOrFetchAsync(2);

            // Assert
            Assert.Equal("Value for key 1", result1);
            Assert.Equal("Value for key 2", result2);
            Assert.Equal("Value for key 1", result3);
            Assert.Equal("Value for key 2", result4);
        }
Esempio n. 2
0
        public async Task OnGet(int key = 0)
        {
            var watch = Stopwatch.StartNew();

            CachedValue = await _fakeServiceDates.GetOrFetchAsync(key);

            watch.Stop();
            TimeConsumed = watch.ElapsedMilliseconds + " ms";
        }
Esempio n. 3
0
 public async Task Cached_Cached_Hit()
 {
     await _cached.GetOrFetchAsync("Cached_Cached_Hit");
 }