Exemplo n.º 1
0
 private async Task GetOrAddAsync()
 {
     await AsyncCacheProvider.GetOrAddAsync(
         CustomerKey,
         () => Task.Factory.StartNew(() => new Customer {
         CustomerId = 1
     }),
         configurator => configurator.SetSlidingExpiration(Expiration));
 }
Exemplo n.º 2
0
        public async Task Cache_Can_RemoveAsync()
        {
            await GetOrAddAsync();

            Assert.IsTrue(AsyncCacheProvider.ContainsAsync(CustomerKey).Result);

            await AsyncCacheProvider.RemoveAsync(CustomerKey);

            Assert.IsFalse(AsyncCacheProvider.ContainsAsync(CustomerKey).Result);
        }