目前Redis已经更新到了6.0.2,那目前StackExchange.Redis 和 ServiceStack.Redis 两个客户端有什么区别呢?
StackExchange.Redis 客户端是开源免费,而ServiceStack.Redis目前我测试了4.0以上版本就有每个小时6000的限制。性能方面,对比测试,ServiceStack比StackExchange性能上高将近50%。
以上分别是5000条和10w条数据写入读入比对,我这是将ServiceStack解除了每小时6000条数据的限制,以下是测试代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
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区别详解的文章就介绍到这了,更多相关ServiceStack.Redis和StackExchange.Redis区别内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!
原文链接:https://blog.csdn.net/qq_32911691/article/details/124171133