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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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)); }
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); } }
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); } } }
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()); } }