Exemplo n.º 1
0
        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);

            //NewRedisClient2 client = new NewRedisClient2(endpoit);
            //TestClient2(client);
            NewRedisClient3 client3 = new NewRedisClient3(endpoit);
            //TestClient3(client3);
            NewRedisClient4 client4 = new NewRedisClient4(endpoit);
            //TestClient3(client3);
            //TestClient2(client);
            //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);
            redisClient.FlushDb();
            SendFromStackExchangeRedis(sedb);
            redisClient.FlushDb();
            SendFromNewSocketRedis3(client3, sedb);
            redisClient.FlushDb();
            SendFromNewSocketRedis4(client4, sedb);
            Console.WriteLine("====== 以上预热 =======");
            //seredis.get
            //SendFromNewSocketRedis2(client, seredis.GetDatabase(0));
            redisClient.FlushDb();
            SendFromFreeRedis(redisClient);
            redisClient.FlushDb();
            SendFromStackExchangeRedis(sedb);
            redisClient.FlushDb();
            SendFromNewSocketRedis3(client3, sedb);
            redisClient.FlushDb();
            SendFromNewSocketRedis4(client4, sedb);
            //redisClient.FlushDb();
            //SendFromFreeRedis(redisClient);
            ////SendFromNewSocketRedis(client, seredis.GetDatabase(0));
            //SendFromStackExchangeRedis(sedb);

            //_sendQueue = new ConcurrentQueue<TaskWithBytes>();
            //_receiverQueue = new ConcurrentQueue<TaskCompletionSource<bool>>();

            ////NewSocketTest(endpoit);
            ////result = client.Set("newRedis", "natasha").Result;
            ////Console.WriteLine(result);
            //Server(endpoit);
            //Test(endpoit);
            //Task.Run(async () =>
            //{
            //    await Task.Delay(5000);
            //    Console.WriteLine();
            //    Console.WriteLine(_sendQueue.Count);
            //    Console.WriteLine(_receiverQueue.Count);

            //});
            Console.ReadKey();
        }
Exemplo n.º 2
0
        private async static void Configuration()
        {
            _options = new ParallelOptions();
            _options.MaxDegreeOfParallelism = 4;
            _useDelay   = true;
            _delayCount = 8000;
            //Notice : Please use "//" comment "/*".

            ///*
            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;
             * //*/

            // NewLife.Redis
            // _newLifeRedis = new NewLife.Caching.Redis($"{ip}:{port}",null, 1);
            //var result = newLifeRedis.Set("1", "1");
            //Console.WriteLine(result);
            //Console.ReadKey();
            //_beetleClient = new BeetleX.Redis.RedisDB(0);
            //var host = _beetleClient.Host.AddWriteHost(ip, port);
            //host.MaxConnections = 1000;
            //host.QueueMaxLength = 512;
            //_freeRedisClient = new RedisClient($"{ip}:{port},database=0,min pool size=100");


            _redisClient161 = new NewRedisClient161();
            _redisClient161.CreateConnection(ip, port);
            //_redisClient161.AuthAsync(pwd);

            _redisClient162 = new NewRedisClient162();
            _redisClient162.CreateConnection(ip, port);
            //_redisClient162.AuthAsync(pwd);

            _redisClient21 = new NewRedisClient21();
            _redisClient21.CreateConnection(ip, port);
            _redisClient21.AuthAsync(pwd);



            _redisClient22 = new NewRedisClient22();
            _redisClient22.CreateConnection(ip, port);
            _redisClient22.AuthAsync(pwd);

            //var result = await _redisClient22.SetAsync("1","1");
            //Console.WriteLine(result);
            //result = await _redisClient22.SetAsync("1", "1");
            //Console.WriteLine(result);

            _redisClient23 = new NewRedisClient23();
            _redisClient23.CreateConnection(ip, port);
            _redisClient23.AuthAsync(pwd);

            _redisClient24 = new NewRedisClient24();
            _redisClient24.CreateConnection(ip, port);
            _redisClient24.AuthAsync(pwd);

            _redisClient4 = new NewRedisClient4();
            _redisClient4.CreateConnection(ip, port);
            _redisClient4.AuthAsync(pwd);

            seredis = ConnectionMultiplexer.Connect($"{ip}:{port},password={pwd}");
            _stackExnchangeClient = seredis.GetDatabase(0);
            //T();
            //Console.ReadKey();
        }
Exemplo n.º 3
0
        private static void Configuration()
        {
            _useDelay   = true;
            _delayCount = 15000;
            //Notice : Please use "//" comment "/*".

            ///*
            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;
             * //*/

            // NewLife.Redis
            // _newLifeRedis = new NewLife.Caching.Redis($"{ip}:{port}",null, 1);
            //var result = newLifeRedis.Set("1", "1");
            //Console.WriteLine(result);
            //Console.ReadKey();
            //_beetleClient = new BeetleX.Redis.RedisDB(0);
            //var host = _beetleClient.Host.AddWriteHost(ip, port);
            //host.MaxConnections = 1000;
            //host.QueueMaxLength = 512;
            //_freeRedisClient = new RedisClient($"{ip}:{port},database=0,min pool size=100");
            //_redisClient0 = new NewRedisClient0(ip, port);

            //_pool4 = new ClientPool1<NewRedisClient4>(ip, port);
            //_pool5 = new ClientPool1<NewRedisClient5>(ip, port);
            //_pool7 = new ClientPool1<NewRedisClient7>(ip, port);
            //_pool9 = new ClientPool1<NewRedisClient9>(ip, port);
            //_pool27 = new ClientPool2<NewRedisClient7>(ip, port);
            //_pool25 = new ClientPool2<NewRedisClient5>(ip, port);
            //_pool24 = new ClientPool2<NewRedisClient4>(ip, port);
            //_redisClient1 = new NewRedisClient1(ip, port);
            //_redisClient2 = new NewRedisClient2(ip, port);
            //_redisClient3 = new NewRedisClient3(ip, port);
            //_redisClient12 = new NewRedisClient12();
            //_redisClient12.CreateConnection(ip, port);
            _redisClient14 = new NewRedisClient14();
            _redisClient14.CreateConnection(ip, port);
            _redisClient14.AuthAsync(pwd);
            _redisClient4 = new NewRedisClient4();
            _redisClient4.CreateConnection(ip, port);
            _redisClient4.AuthAsync(pwd);
            //_redisClient4.AuthAsync(pwd);
            //_redisClient5 = _pool5._node;
            //_redisClient7 = _pool7._node;
            //_redisClient8 = new NewRedisClient8();
            //_redisClient8.CreateConnection(ip, port);
            _redisClient9 = new NewRedisClient9();
            _redisClient9.CreateConnection(ip, port);
            _redisClient9.AuthAsync(pwd);
            ///_pool13 = new ClientPool4(ip, port);
            //_pool13.AuthAsync(pwd);
            _pool10 = new ClientPool3(ip, port);
            _pool10.AuthAsync(pwd);
            _pool14 = new ClientPool5(ip, port);
            _pool14.AuthAsync(pwd);
            //_redisClient5.SetAsync("a", "a");
            seredis = ConnectionMultiplexer.Connect($"{ip}:{port},password={pwd}");
            _stackExnchangeClient = seredis.GetDatabase(0);


            //_beforeSw = (str) =>
            //{
            //    if (str.Contains("Pool10"))
            //    {
            //        _pool10.Start();
            //    }
            //};
        }