public static void Main(string[] args) { var iterations = 10; try { var builder = new Core.ConfigurationBuilder("myCache"); builder.WithMicrosoftLogging(f => { f.AddConsole(LogLevel.Warning); f.AddDebug(LogLevel.Debug); }); builder.WithRetryTimeout(100); builder.WithMaxRetries(5); builder.WithDictionaryHandle() .WithExpiration(ExpirationMode.Absolute, TimeSpan.FromSeconds(20)) .DisableStatistics(); builder.WithRedisCacheHandle("redis", true) .WithExpiration(ExpirationMode.Sliding, TimeSpan.FromSeconds(60)) .DisableStatistics(); builder.WithRedisBackplane("redis"); builder.WithRedisConfiguration("redis", config => { config .WithAllowAdmin() .WithDatabase(0) .WithConnectionTimeout(5000) .WithEndpoint("127.0.0.1", 6379); }); //builder.WithGzJsonSerializer(); builder.WithBondCompactBinarySerializer(); #if !NETCOREAPP //var memcachedCfg = new MemcachedClientConfiguration(); //memcachedCfg.AddServer("localhost", 11211); //builder.WithMemcachedCacheHandle(memcachedCfg); #endif var cacheA = new BaseCacheManager <string>(builder.Build()); cacheA.Clear(); for (var i = 0; i < iterations; i++) { var redisHandle = cacheA.CacheHandles.OfType <RedisCacheHandle <string> >().First(); foreach (var server in redisHandle.Servers) { Console.WriteLine($"{server.ToString()}=>{server.EndPoint} connected:{server.IsConnected} isSlave:{server.IsSlave}"); } try { Tests.PutAndMultiGetTest(cacheA); } catch (AggregateException ex) { ex.Handle((e) => { Console.WriteLine(e); return(true); }); } catch (Exception e) { Console.WriteLine("Error: " + e.Message + "\n" + e.StackTrace); Thread.Sleep(1000); } Console.WriteLine("---------------------------------------------------------"); } } catch (Exception ex) { Console.WriteLine(ex); } Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("We are done..."); Console.ForegroundColor = ConsoleColor.Gray; Console.ReadKey(); }
public void Main(string[] args) { int iterations = int.MaxValue; try { var builder = new Core.ConfigurationBuilder("myCache"); builder.WithMicrosoftLogging(f => { // TODO: remove after logging upgrade to RC2 f.MinimumLevel = LogLevel.Debug; f.AddConsole(LogLevel.Error); // TODO: change to Debug after logging upgrade to RC2 f.AddDebug(LogLevel.Verbose); }); builder.WithUpdateMode(CacheUpdateMode.Up); builder.WithRetryTimeout(1000); builder.WithMaxRetries(10); #if DNXCORE50 builder.WithDictionaryHandle("dic") .DisableStatistics(); //Console.WriteLine("Using Dictionary cache handle"); #else builder.WithDictionaryHandle() .DisableStatistics(); builder.WithRedisCacheHandle("redis", true) .DisableStatistics(); builder.WithRedisBackPlate("redis"); builder.WithRedisConfiguration("redis", config => { config .WithAllowAdmin() .WithDatabase(0) .WithConnectionTimeout(5000) .WithEndpoint("127.0.0.1", 6380) .WithEndpoint("127.0.0.1", 6379); //.WithEndpoint("192.168.178.34", 7001); }); builder.WithJsonSerializer(); Console.WriteLine("Using Redis cache handle"); #endif var cacheA = new BaseCacheManager <object>(builder.Build()); cacheA.Clear(); var manualConfig = new CacheManagerConfiguration(); manualConfig.CacheHandleConfigurations.Add(new CacheHandleConfiguration() { HandleType = typeof(Core.Internal.DictionaryCacheHandle <>) }); var cacheB = new BaseCacheManager <string>("name", manualConfig); for (int i = 0; i < iterations; i++) { try { Tests.PutAndMultiGetTest(cacheA); } catch (AggregateException ex) { ex.Handle((e) => { Console.WriteLine(e); return(true); }); } catch (Exception e) { Console.WriteLine("Error: " + e.Message + "\n" + e.StackTrace); Thread.Sleep(1000); } Console.WriteLine("---------------------------------------------------------"); } } catch (Exception ex) { Console.WriteLine(ex); } Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("We are done..."); Console.ForegroundColor = ConsoleColor.Gray; Console.ReadKey(); }
public static void Main(string[] args) { var configBuilder = new Microsoft.Extensions.Configuration.ConfigurationBuilder() .AddJsonFile("cache.json"); var configuration = configBuilder.Build(); ////var cacheCfgf = configuration.GetCacheConfigurations().First(); ////var mgr = new BaseCacheManager<string>(cacheCfgf); int iterations = int.MaxValue; try { var builder = new Core.ConfigurationBuilder("myCache"); builder.WithMicrosoftLogging(f => { f.AddConsole(LogLevel.Warning); f.AddDebug(LogLevel.Debug); }); builder.WithUpdateMode(CacheUpdateMode.Up); builder.WithRetryTimeout(1000); builder.WithMaxRetries(10); //#if NETCORE // builder.WithDictionaryHandle("dic") // .DisableStatistics(); // //Console.WriteLine("Using Dictionary cache handle"); //#else builder.WithDictionaryHandle() .DisableStatistics(); builder.WithRedisCacheHandle("redis", true) .DisableStatistics(); builder.WithRedisBackplane("redis"); builder.WithRedisConfiguration("redis", config => { config .WithAllowAdmin() .WithDatabase(0) .WithConnectionTimeout(5000) //.WithEndpoint("ubuntu-local", 7024); //.WithEndpoint("127.0.0.1", 6380) .WithEndpoint("127.0.0.1", 6379); //.WithEndpoint("192.168.178.34", 7001); }); builder.WithJsonSerializer(); Console.WriteLine("Using Redis cache handle"); //#endif var cacheA = new BaseCacheManager <object>(builder.Build()); cacheA.Clear(); for (int i = 0; i < iterations; i++) { try { Tests.PutAndMultiGetTest(cacheA); } catch (AggregateException ex) { ex.Handle((e) => { Console.WriteLine(e); return(true); }); } catch (Exception e) { Console.WriteLine("Error: " + e.Message + "\n" + e.StackTrace); Thread.Sleep(1000); } Console.WriteLine("---------------------------------------------------------"); } } catch (Exception ex) { Console.WriteLine(ex); } Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("We are done..."); Console.ForegroundColor = ConsoleColor.Gray; Console.ReadKey(); }
public static void Main(string[] args) { int iterations = 10; try { var builder = new Core.ConfigurationBuilder("myCache"); builder.WithMicrosoftLogging(f => { f.AddConsole(LogLevel.Warning); f.AddDebug(LogLevel.Debug); }); builder.WithRetryTimeout(1000); builder.WithMaxRetries(10); builder.WithDictionaryHandle() .WithExpiration(ExpirationMode.Absolute, TimeSpan.FromSeconds(20)) .DisableStatistics(); builder.WithRedisCacheHandle("redis", true) .WithExpiration(ExpirationMode.Sliding, TimeSpan.FromSeconds(60)) .DisableStatistics(); builder.WithRedisBackplane("redis"); builder.WithRedisConfiguration("redis", config => { config .WithAllowAdmin() .WithDatabase(0) .WithConnectionTimeout(5000) .WithEndpoint("127.0.0.1", 6379); }); builder.WithJsonSerializer(); var cacheA = new BaseCacheManager <object>(builder.Build()); cacheA.Clear(); for (int i = 0; i < iterations; i++) { try { Tests.PutAndMultiGetTest(cacheA); } catch (AggregateException ex) { ex.Handle((e) => { Console.WriteLine(e); return(true); }); } catch (Exception e) { Console.WriteLine("Error: " + e.Message + "\n" + e.StackTrace); Thread.Sleep(1000); } Console.WriteLine("---------------------------------------------------------"); } } catch (Exception ex) { Console.WriteLine(ex); } Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("We are done..."); Console.ForegroundColor = ConsoleColor.Gray; Console.ReadKey(); }
public static void Main(string[] args) { ThreadPool.SetMinThreads(100, 100); var iterations = 100; try { var builder = new Core.ConfigurationBuilder("myCache"); builder.WithMicrosoftLogging(f => { f.AddConsole(LogLevel.Warning); ////f.AddDebug(LogLevel.Debug); }); builder .WithRetryTimeout(500) .WithMaxRetries(3); builder .WithDictionaryHandle() .WithExpiration(ExpirationMode.Absolute, TimeSpan.FromSeconds(20)) .DisableStatistics(); builder .WithRedisCacheHandle("redis", true) .WithExpiration(ExpirationMode.Sliding, TimeSpan.FromSeconds(60)) .DisableStatistics(); builder.WithRedisBackplane("redis"); builder.WithRedisConfiguration("redis", config => { config //.UseTwemproxy() //.UseCompatibilityMode("2.4") .WithAllowAdmin() .WithDatabase(0) .WithConnectionTimeout(5000) .EnableKeyspaceEvents() .WithEndpoint("127.0.0.1", 6379); }); //builder.WithRedisConfiguration("redis", "localhost:22121"); builder.WithBondCompactBinarySerializer(); #if !NETCOREAPP //var memcachedCfg = new MemcachedClientConfiguration(); //memcachedCfg.AddServer("localhost", 11211); //builder.WithMemcachedCacheHandle(memcachedCfg); #endif var cacheA = new BaseCacheManager <string>(builder.Build()); cacheA.Clear(); for (var i = 0; i < iterations; i++) { try { Tests.PumpData(cacheA).GetAwaiter().GetResult(); break; // specified runtime (todo: rework this anyways) } catch (AggregateException ex) { ex.Handle((e) => { Console.WriteLine(e); return(true); }); } catch (Exception e) { Console.WriteLine("Error: " + e.Message + "\n" + e.StackTrace); Thread.Sleep(1000); } Console.WriteLine("---------------------------------------------------------"); } } catch (Exception ex) { Console.WriteLine(ex); } Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("We are done..."); Console.ForegroundColor = ConsoleColor.Gray; Console.ReadKey(); }
public void Main(string[] args) { int iterations = int.MaxValue; try { var builder = new Core.ConfigurationBuilder("myCache"); builder.WithMicrosoftLogging(f => { // TODO: remove after logging upgrade to RC2 f.MinimumLevel = LogLevel.Debug; f.AddConsole(LogLevel.Error); // TODO: change to Debug after logging upgrade to RC2 f.AddDebug(LogLevel.Information); }); builder.WithUpdateMode(CacheUpdateMode.Up); builder.WithRetryTimeout(1000); builder.WithMaxRetries(10); #if DNXCORE50 builder.WithDictionaryHandle("dic") .DisableStatistics(); //Console.WriteLine("Using Dictionary cache handle"); #else builder.WithDictionaryHandle() .DisableStatistics(); builder.WithRedisCacheHandle("redis", true) .DisableStatistics(); builder.WithRedisBackplane("redis"); builder.WithRedisConfiguration("redis", config => { config .WithAllowAdmin() .WithDatabase(0) .WithConnectionTimeout(5000) //.WithEndpoint("ubuntu-local", 7024); .WithEndpoint("127.0.0.1", 6380) .WithEndpoint("127.0.0.1", 6379); //.WithEndpoint("192.168.178.34", 7001); }); builder.WithJsonSerializer(); Console.WriteLine("Using Redis cache handle"); #endif var cacheA = new BaseCacheManager<object>(builder.Build()); cacheA.Clear(); for (int i = 0; i < iterations; i++) { try { Tests.PutAndMultiGetTest(cacheA); } catch (AggregateException ex) { ex.Handle((e) => { Console.WriteLine(e); return true; }); } catch (Exception e) { Console.WriteLine("Error: " + e.Message + "\n" + e.StackTrace); Thread.Sleep(1000); } Console.WriteLine("---------------------------------------------------------"); } } catch (Exception ex) { Console.WriteLine(ex); } Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("We are done..."); Console.ForegroundColor = ConsoleColor.Gray; Console.ReadKey(); }
public static void Main(string[] args) { var configBuilder = new Microsoft.Extensions.Configuration.ConfigurationBuilder() .AddJsonFile("cache.json"); var configuration = configBuilder.Build(); ////var cacheCfgf = configuration.GetCacheConfigurations().First(); ////var mgr = new BaseCacheManager<string>(cacheCfgf); int iterations = int.MaxValue; try { var builder = new Core.ConfigurationBuilder("myCache"); builder.WithMicrosoftLogging(f => { f.AddConsole(LogLevel.Warning); f.AddDebug(LogLevel.Debug); }); builder.WithUpdateMode(CacheUpdateMode.Up); builder.WithRetryTimeout(1000); builder.WithMaxRetries(10); //#if NETCORE // builder.WithDictionaryHandle("dic") // .DisableStatistics(); // //Console.WriteLine("Using Dictionary cache handle"); //#else builder.WithDictionaryHandle() .DisableStatistics(); builder.WithRedisCacheHandle("redis", true) .DisableStatistics(); builder.WithRedisBackplane("redis"); builder.WithRedisConfiguration("redis", config => { config .WithAllowAdmin() .WithDatabase(0) .WithConnectionTimeout(5000) //.WithEndpoint("ubuntu-local", 7024); //.WithEndpoint("127.0.0.1", 6380) .WithEndpoint("127.0.0.1", 6379); //.WithEndpoint("192.168.178.34", 7001); }); builder.WithJsonSerializer(); Console.WriteLine("Using Redis cache handle"); //#endif var cacheA = new BaseCacheManager<object>(builder.Build()); cacheA.Clear(); for (int i = 0; i < iterations; i++) { try { Tests.PutAndMultiGetTest(cacheA); } catch (AggregateException ex) { ex.Handle((e) => { Console.WriteLine(e); return true; }); } catch (Exception e) { Console.WriteLine("Error: " + e.Message + "\n" + e.StackTrace); Thread.Sleep(1000); } Console.WriteLine("---------------------------------------------------------"); } } catch (Exception ex) { Console.WriteLine(ex); } Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("We are done..."); Console.ForegroundColor = ConsoleColor.Gray; Console.ReadKey(); }