예제 #1
0
        public async Task Flush_WhenAnEntityOfType1AndType2AreAdded_ThenFlushed_ThenStoreMustBeEmpty()
        {
            // arrange
            var entity1 = TestCompany.Apple;
            var entity2 = new TestPerson {
                FirstName = "test2", Id = "1", LastName = "test2"
            };

            await _cacheType1.SetAsync(new[] { entity1 });

            await _cacheType2.SetAsync(new[] { entity2 });

            // act (flush type 1)
            await _cacheType1.ClearAsync();

            var entity1Found = await _cacheType1.GetAsync(entity1.Id);

            var entity2Found = await _cacheType2.GetAsync(entity2.Id);

            // assert
            Assert.That(entity1Found, Is.Null);
            Assert.That(entity2Found, Is.EqualTo(entity2));

            // act (flush type 2)
            await _cacheType2.ClearAsync();

            entity1Found = await _cacheType1.GetAsync(entity1.Id);

            entity2Found = await _cacheType2.GetAsync(entity2.Id);

            // assert
            Assert.That(entity1Found, Is.Null);
            Assert.That(entity2Found, Is.Null);
        }
예제 #2
0
        public async Task AddOrUpdate_WhenAnEntityIsAddedWithExpiryOf1Second_ThenItCannotBeRetrieved()
        {
            // arrange
            var entity = TestCompany.Apple;

            // act
            await _cacheType1WithExpiry.AddOrUpdateAsync(entity);

            var retrievedEntityBeforeExpiry = await _cacheType1WithExpiry.GetAsync(entity.Id);

            await Task.Delay(1500);

            var retrievedEntityAfterExpiry = await _cacheType1WithExpiry.GetAsync(entity.Id);

            // assert
            Assert.That(retrievedEntityBeforeExpiry, Is.EqualTo(entity));
            Assert.That(retrievedEntityAfterExpiry, Is.Null);
        }
예제 #3
0
        static void Main()
        {
            Console.BackgroundColor = ConsoleColor.DarkGreen;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.Clear();
            var client = new RedisStore("localhost:6379").CreateClient();

            client.BaseAddress = new Uri("http://localhost:1337");
            while (true)
            {
                var response = client.GetAsync("/time").Result;
                var data     = response.Content.ReadAsStringAsync().Result;
                Console.WriteLine(data);
                Console.WriteLine(response.Headers.CacheControl.ToString());
                if (Console.ReadLine() == "done")
                {
                    break;
                }
            }
        }
예제 #4
0
        public async Task AddOrUpdate_WhenAnEntityIsAdded_ThenItCanBeRetrieved()
        {
            // arrange
            var entity = TestCompany.Apple;

            // act
            await _cacheType1.AddOrUpdateAsync(entity);

            var retrievedEntity = await _cacheType1.GetAsync(entity.Id);

            // assert
            Assert.That(retrievedEntity, Is.EqualTo(entity));
        }