您好,登錄后才能下訂單哦!
本文小編為大家詳細介紹“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區別是什么”文章已經介紹完畢,想要掌握這篇文章的知識點還需要大家自己動手實踐使用過才能領會,如果想了解更多相關內容的文章,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。