Redis中ServiceStack.Redis和StackExchange.Redis区别是什么
本文小编为大家详细介绍“Redis中ServiceStack.Redis和StackExchange.Redis区别是什么”,内容详细,步骤清晰,细节处理妥当,希望这篇“Redis中ServiceStack.Redis和StackExchange.Redis区别是什么”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。
StackExchange.Redis 客户端是开源免费,而ServiceStack.Redis目前我测试了4.0以上版本就有每个小时6000的限制。性能方面,对比测试,ServiceStack比StackExchange性能上高将近50%。
以上分别是5000条和10w条数据写入读入比对,我这是将ServiceStack解除了每小时6000条数据的限制,以下是测试代码:
static void Main(string[] args) { DateTime time1 = DateTime.Now; DateTime time2 = DateTime.Now; #region StackExchange { IConnectionMultiplexer proxy = ConnectionMultiplexer.Connect("127.0.0.1,abortConnect=false"); //proxy.GetServer("host",6379).FlushDatabase(0); IDatabase db = proxy.GetDatabase(); db.KeyDelete("Key1"); time1 = DateTime.Now; for (int i = 0; i < 100000; i++) { db.StringSet("Key1", "这是StackExchange"); } time2 = DateTime.Now; Console.WriteLine("StackExchange 赋值 100000 次, 耗时: {0} 秒", (time2 - time1).TotalSeconds); time1 = DateTime.Now; for (int i = 0; i < 100000; i++) { RedisValue value = db.StringGet("Key1"); } time2 = DateTime.Now; Console.WriteLine("StackExchange 取值 100000 次, 耗时: {0} 秒", (time2 - time1).TotalSeconds); Console.WriteLine("----------------------------------"); } #endregion #region ServiceStack using (RedisClient redisClient = new RedisClient("127.0.0.1", 6379)) { redisClient.FlushDb(); redisClient.FlushAll(); time1 = DateTime.Now; for (int i = 0; i < 100000; i++) { redisClient.Set("Key2", "这是ServiceStack"); } time2 = DateTime.Now; Console.WriteLine("ServiceStack 赋值 100000 次, 耗时: {0} 秒", (time2 - time1).TotalSeconds); Thread.Sleep(1000); time1 = DateTime.Now; for (int i = 0; i < 100000; i++) { redisClient.Get<string>("Key2"); } time2 = DateTime.Now; Console.WriteLine("ServiceStack 取值 100000 次, 耗时: {0} 秒", (time2 - time1).TotalSeconds); Console.WriteLine("----------------------------------"); } #endregion }
读到这里,这篇“Redis中ServiceStack.Redis和StackExchange.Redis区别是什么”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注蜗牛博客行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:niceseo99@gmail.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。版权声明:如无特殊标注,文章均为本站原创,转载时请以链接形式注明文章出处。
评论