健康一贴灵,专注医药行业管理信息化

C# 连接redis ,生成1亿个20位长随机数做测试

 

            string buffer = "0123456789";// 随机字符中也可以为汉字(任何)
            string abc = "";
            IRedisClient client = RedisManager.GetClient();
            StringBuilder sb = new StringBuilder(20);
            Random r = new Random();
            int range = 10;
            int iLength = 20;
            //生成1亿个20位长的数字随机数
            DateTime dt = DateTime.Now;
            for (int k = 0; k <= 100000000; k++)
            {
                for (int i = 0; i < iLength; i++)
                {
                    sb.Append(buffer.Substring(r.Next(range), 1));
                }
                client.AddItemToSet("msfx", sb.ToString());
                Console.WriteLine("第{0}个数:{1}", k, sb.ToString());
                //清空
                sb.Length = 0;
            }
            DateTime dt2 = DateTime.Now;
            Console.WriteLine("执行用时:", dt2, dt);
            Console.WriteLine("执行用时:", dt2 - dt);
        

 

posted @ 2023-07-12 10:07  一贴灵  阅读(28)  评论(1编辑  收藏  举报
学以致用,效率第一