예제 #1
0
        public void CustomersCache()
        {
            var categoryManager = new EntitiesManager <Customer>(new MemoryCache <IEnumerable <Customer> >());

            for (var i = 0; i < 10; i++)
            {
                Console.WriteLine(categoryManager.GetEntities().Count());
                Thread.Sleep(100);
            }
        }
예제 #2
0
        public void CustomersUsingRedisCache()
        {
            var entityManager = new EntitiesManager <Customer>(new EntitiesRedisCache <Customer>("localhost"));

            for (var i = 0; i < 10; i++)
            {
                Console.WriteLine(entityManager.GetEntities().Count());
                Thread.Sleep(100);
            }
        }
예제 #3
0
        public void RedisCache()
        {
            var categoryManager = new EntitiesManager <Category>(new RedisCache <IEnumerable <Category> >("localhost"));

            for (var i = 0; i < 10; i++)
            {
                Console.WriteLine(categoryManager.GetEntities().Count());
                Thread.Sleep(100);
            }
        }
예제 #4
0
        public void SuppliersRedisCache()
        {
            var entitiesManager = new EntitiesManager <Supplier>(new RedisCache <IEnumerable <Supplier> >("localhost", _suppliersPrefix));

            for (var i = 0; i < 10; i++)
            {
                Console.WriteLine(entitiesManager.GetEntities().Count());
                Thread.Sleep(100);
            }
        }
예제 #5
0
        public void CustomersUsingMemoryCache()
        {
            var entityManager = new EntitiesManager <Customer>((new EntitiesMemoryCache <Customer>()));

            for (var i = 0; i < 10; i++)
            {
                Console.WriteLine(entityManager.GetEntities().Count());
                Thread.Sleep(100);
            }
        }
예제 #6
0
        public void CategoriesMemoryCache()
        {
            var entitiesManager = new EntitiesManager <Category>(new MemoryCache <IEnumerable <Category> >(_categoriesPrefix));

            for (var i = 0; i < 10; i++)
            {
                Console.WriteLine(entitiesManager.GetEntities().Count());
                Thread.Sleep(100);
            }
        }
예제 #7
0
        public void MemoryCacheGenericSupplierWithOutInvalidation()
        {
            var entityManager = new EntitiesManager <Supplier>(new EntitiesMemoryCache <Supplier>());

            for (var i = 0; i < 10; i++)
            {
                Console.WriteLine(entityManager.GetEntities().Count());
                Thread.Sleep(1000);
            }
        }
예제 #8
0
        public void RedisCacheGenericOrder()
        {
            var entityManager = new EntitiesManager <Order>(new EntitiesRedisCache <Order>("localhost"));

            for (var i = 0; i < 10; i++)
            {
                Console.WriteLine(entityManager.GetEntities().Count());
                Thread.Sleep(100);
            }
        }
        public void RedisCache()
        {
            var categoryManager = new EntitiesManager(new CategoriesRedisCache("localhost"));
            var productManager  = new EntitiesManager(new ProductsRedisCache("localhost"));

            for (var i = 0; i < 10; i++)
            {
                Console.WriteLine(categoryManager.GetCategories().Count());
                Console.WriteLine(productManager.GetProducts().Count());
                Thread.Sleep(100);
            }
        }
예제 #10
0
        public void ExcpirationTimeTestInvalidation()
        {
            var entitycache   = new Mock <IEntitiesCache <Category> >();
            var entityManager = new EntitiesManager <Category>(entitycache.Object);

            for (var i = 0; i < 10; i++)
            {
                Console.WriteLine(entityManager.GetEntities().Count());
                Thread.Sleep(100);
            }
            entitycache.Verify(
                n => n.Set(It.IsAny <string>(), It.IsAny <IEnumerable <Category> >(), It.IsAny <DateTimeOffset>()), Times.AtLeast(2));
        }
예제 #11
0
        public void MemoryCacheGenericOrderWithTimeInvalidation()
        {
            var entityManager = new EntitiesManager <Order>(new EntitiesMemoryCache <Order>()
            {
                PolicyLevel = PolicyType.ExpirationTime
            });

            for (var i = 0; i < 10; i++)
            {
                Console.WriteLine(entityManager.GetEntities().Count());
                Thread.Sleep(1000);
            }
        }
예제 #12
0
        public void CacheItemPolicy()
        {
            var policy = new CacheItemPolicy();

            policy.ChangeMonitors.Add(new SqlChangeMonitor(new System.Data.SqlClient.SqlDependency(new SqlCommand("Select * from Northwind.Category"))));
            var entitycache   = new Mock <IEntitiesCache <Category> >();
            var entityManager = new EntitiesManager <Category>(entitycache.Object);

            for (var i = 0; i < 10; i++)
            {
                Console.WriteLine(entityManager.GetEntities().Count());
                Thread.Sleep(1000);
            }
            entitycache.Verify(
                n => n.Set(It.IsAny <string>(), It.IsAny <IEnumerable <Category> >(), It.IsAny <DateTimeOffset>()), Times.AtLeast(2));
        }
        public void MemoryCache()
        {
            var categoryManager = new EntitiesManager(new CategoriesMemoryCache());
            var productManager  = new EntitiesManager(new ProductsMemoryCache());

            var productsCount = productManager.GetProducts();

            if (productsCount == null)
            {
                return;
            }
            else
            {
                for (var i = 0; i < 10; i++)
                {
                    Console.WriteLine(categoryManager.GetCategories().Count());
                    Console.WriteLine(productsCount.Count());
                    Thread.Sleep(100);
                }
            }
        }
예제 #14
0
        public void MemoryCacheGenericSupplierWithChangeDbInvalidation()
        {
            var entityManager = new EntitiesManager <Supplier>(new EntitiesMemoryCache <Supplier>
            {
                PolicyLevel = PolicyType.ChangeMonitorSql
            });
            var supplier = new Supplier
            {
                CompanyName = "Company",
                ContactName = "Contact"
            };

            for (var i = 0; i < 10; i++)
            {
                if (i == 5)
                {
                    entityManager.AddItem(supplier);
                }
                Console.WriteLine(entityManager.GetEntities().Count());
            }
        }