예제 #1
0
        private static void Test_Partab_KV()
        {
            //var cnn = ConnectionMultiplexer.Connect("172.17.1.70:10001,172.17.1.70:10002,172.17.1.70:10003,172.17.1.70:10004,172.17.1.70:10005,172.17.1.70:10006");

            //var cnn = ConnectionMultiplexer.Connect("172.17.6.10:6379,172.17.6.11:6379,172.17.6.12:6379,172.17.6.13:6379,172.17.6.14:6379,172.17.6.15:6379");
            var cnn = ConnectionMultiplexer.Connect("172.17.1.70:11111");
            var db = cnn.GetDatabase();
            long cid = 1200700000;
            long gid = 146165;

            var START = 0;
            var COUNT = 1000;
            var rnd = new Random();

            var data = new Partab[COUNT];
            for (int i = 0; i < data.Length; i++)
            {
                var d = new Partab
                {
                    cid = rnd.Next(1000000, int.MaxValue),
                    gid = START + i,
                    FeedbackType = rnd.Next(1000000, int.MaxValue),
                    foldid = rnd.Next(1000000, int.MaxValue),
                    is_active_for_company = "y",
                    is_temporary = "y",
                    LabelType = i,
                    mdate = DateTime.Now,
                    pid = rnd.Next(1000000, int.MaxValue),
                    pnumber = "CC000043927J90250331000",
                    PostType = i,
                    public_label = i,
                    resume_source_id = i,
                    rid = rnd.Next(1000000, int.MaxValue),
                    rnumber = "JM346841194R90250000000",
                    rootid = 12007000 + i,
                    rversion = i,
                    uid = rnd.Next(1000000, int.MaxValue)
                };

                data[i] = d;
            }

            var tasks = new Task<bool>[COUNT];
            var sw = Stopwatch.StartNew();
            var expireSpan = new TimeSpan(90, 0, 0, 0);
            for (int i = 0; i < data.Length; i++)
            {
                var item = data[i];
                var json = JsonConvert.SerializeObject(item);
                tasks[i] = db.StringSetAsync("gid_:" + item.gid.ToString(), json, expireSpan);
                //db.StringSet("gid_:" + item.gid.ToString(), json, expireSpan);
            }
            try
            {

                Task.WaitAll(tasks);
                sw.Stop();
                cnn.Close();
            }
            catch (Exception ex)
            {

                var tt = tasks.Where(i => i.IsFaulted == true).ToList();
                foreach (var item in ex.Data.Keys)
                {
                    var o = ex.Data[item];
                    var test = o;
                }
                cnn.Close();
                throw;
            }

            Console.WriteLine(sw.ElapsedMilliseconds);
        }
예제 #2
0
        private static void Test_Partab_Hash()
        {
            //var cnn = ConnectionMultiplexer.Connect("172.17.1.70:10001,172.17.1.70:10002,172.17.1.70:10003,172.17.1.70:10004,172.17.1.70:10005,172.17.1.70:10006");
            var cnn = ConnectionMultiplexer.Connect("172.17.1.70:11111");
            var db = cnn.GetDatabase();

            var result = db.HashGetAll("gid_100");

            db.HashSet("gid_100", "rootid", 9999);

            result = db.HashGetAll("gid_100");

            var sw = Stopwatch.StartNew();
            long cid = 1200700000;
            long gid = 146165;

            var COUNT = 100;
            var rnd = new Random();

            var data = new Partab[COUNT];
            for (int i = 0; i < +data.Length; i++)
            {
                var d = new Partab
                {
                    cid = rnd.Next(1000000, int.MaxValue),
                    gid = i,
                    FeedbackType = rnd.Next(1000000, int.MaxValue),
                    foldid = rnd.Next(1000000, int.MaxValue),
                    is_active_for_company = "y",
                    is_temporary = "y",
                    LabelType = i,
                    mdate = DateTime.Now,
                    pid = rnd.Next(1000000, int.MaxValue),
                    pnumber = "CC000043927J90250331000",
                    PostType = i,
                    public_label = i,
                    resume_source_id = i,
                    rid = rnd.Next(1000000, int.MaxValue),
                    rnumber = "JM346841194R90250000000",
                    rootid = 12007000 + i,
                    rversion = i,
                    uid = rnd.Next(1000000, int.MaxValue)
                };

                data[i] = d;
            }

            var tasks = new Task<bool>[COUNT];
            for (int i = 0; i < data.Length; i++)
            {
                var item = data[i];
                var json = JsonConvert.SerializeObject(item);
                tasks[i] = db.HashSetAsync("h_gid", item.gid.ToString(), json);
                //tasks[i] = db.StringSetAsync("gid_:" + item.gid.ToString(), json);
            }
            Task.WaitAll(tasks);
            sw.Stop();

            Console.WriteLine(sw.ElapsedMilliseconds);
        }