static void Main(string[] args) { //using (StreamReader stream = new StreamReader("Redis.rsf")) //{ // ip = stream.ReadLine(); // port = int.Parse(stream.ReadLine()); // //pwd = stream.ReadLine(); //} ip = "127.0.0.1"; port = 6379; var endpoit = new IPEndPoint(IPAddress.Parse(ip), port); //new NewRedisClient client = new NewRedisClient(endpoit); var result = client.SelectDB(0).Result; client.Set("test01", "123123").Wait(); //FreeRedis var redisClient = new RedisClient($"{ip}:{port},database=15,min pool size=100"); //StackExchange ConnectionMultiplexer seredis = ConnectionMultiplexer.Connect("127.0.0.1:6379"); IDatabase sedb = seredis.GetDatabase(1); redisClient.FlushDb(); //SendFromFreeRedis(redisClient); SendFromFreeRedis(redisClient); //SendFromNewSocketRedis(client, seredis.GetDatabase(0)); SendFromStackExchangeRedis(sedb); redisClient.FlushDb(); SendFromFreeRedis(redisClient); //SendFromNewSocketRedis(client, seredis.GetDatabase(0)); SendFromStackExchangeRedis(sedb); //NewSocketTest(endpoit); //result = client.Set("newRedis", "natasha").Result; //Console.WriteLine(result); //Server(endpoit); //Test(endpoit); Console.ReadKey(); }
public static void SendFromNewSocketRedis(NewRedisClient client, IDatabase sedb) { var tasks = new Task[10000]; Stopwatch sw = new Stopwatch(); sw.Start(); for (var a = 0; a < 10000; a += 1) { tasks[a] = Task.Run(async() => { var tmp = Guid.NewGuid().ToString(); await client.Set(tmp, "Natasha\r\nNatasha"); var val = await sedb.StringGetAsync(tmp); //valid if (val != "Natasha\r\nNatasha") { throw new Exception("not equal"); } }); } Task.WaitAll(tasks); sw.Stop(); Console.WriteLine("NewRedisClient(0-10000): " + sw.ElapsedMilliseconds + "ms"); }