コード例 #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 = 8989;
            var endpoit = new IPEndPoint(IPAddress.Parse(ip), port);

            NewRedisClient2 client = new NewRedisClient2(endpoit);

            TestClient2(client);
            //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);
            SendFromFreeRedis(redisClient);
            SendFromStackExchangeRedis(sedb);
            SendFromNewSocketRedis2(client, seredis.GetDatabase(0));

            //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();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: linchangsheng89/FreeRedis
        private static void InitClient()
        {
            //_useDelay = true;
            _delayCount = 3000;
            //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);
            _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);
            _redisClient4 = _pool4._node;
            _redisClient5 = _pool5._node;
            _redisClient7 = _pool7._node;
            _redisClient8 = new NewRedisClient8();
            _redisClient8.CreateConnection(ip, port);
            _redisClient9 = new NewRedisClient9();
            _redisClient9.CreateConnection(ip, port);
            //_redisClient5.SetAsync("a", "a");
            ConnectionMultiplexer seredis = ConnectionMultiplexer.Connect($"{ip}:{port}");

            _stackExnchangeClient = seredis.GetDatabase(0);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: wenfeifei/FreeRedis
        public static void SendFromNewSocketRedis2(NewRedisClient2 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 key = a.ToString();
                    await client.SetAsync(key, key);
                    var val = await sedb.StringGetAsync(key); //valid
                    if (val != key)
                    {
                        throw new Exception("not equal");
                    }
                });
            }
            Task.WaitAll(tasks);
            sw.Stop();
            Console.WriteLine("NewRedisClient2(0-10000): " + sw.ElapsedMilliseconds + "ms");
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: wenfeifei/FreeRedis
        public static async void TestClient2(NewRedisClient2 client)
        {
            var result = await client.SetAsync("1", "1");

            Console.WriteLine(result);
        }