This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +49
-2
lines changed
tests/ServiceStack.Redis.Tests Expand file tree Collapse file tree 3 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -150,8 +150,12 @@ internal IRedisPipelineShared Pipeline
150
150
internal void EndPipeline ( )
151
151
{
152
152
ResetSendBuffer ( ) ;
153
- Pipeline = null ;
154
- Interlocked . Increment ( ref __requestsPerHour ) ;
153
+
154
+ if ( Pipeline != null )
155
+ {
156
+ Pipeline = null ;
157
+ Interlocked . Increment ( ref __requestsPerHour ) ;
158
+ }
155
159
}
156
160
157
161
public RedisNativeClient ( string connectionString )
Original file line number Diff line number Diff line change
1
+ using System . Collections . Generic ;
2
+ using NUnit . Framework ;
3
+
4
+ namespace ServiceStack . Redis . Tests
5
+ {
6
+ [ TestFixture ]
7
+ public class RedisStatsTests
8
+ : RedisClientTestsBase
9
+ {
10
+ [ TestFixtureSetUp ]
11
+ public void TestFixtureSetUp ( )
12
+ {
13
+ RedisConfig . AssumeServerVersion = 2821 ;
14
+ }
15
+
16
+ [ Test ]
17
+ [ Explicit ]
18
+ public void Batch_and_Pipeline_requests_only_counts_as_1_request ( )
19
+ {
20
+ var reqCount = RedisNativeClient . RequestsPerHour ;
21
+
22
+ var map = new Dictionary < string , string > ( ) ;
23
+ 10 . Times ( i => map [ "key" + i ] = "value" + i ) ;
24
+
25
+ Redis . SetValues ( map ) ;
26
+
27
+ Assert . That ( RedisNativeClient . RequestsPerHour , Is . EqualTo ( reqCount + 1 ) ) ;
28
+
29
+ var keyTypes = new Dictionary < string , string > ( ) ;
30
+ using ( var pipeline = Redis . CreatePipeline ( ) )
31
+ {
32
+ map . Keys . Each ( key =>
33
+ pipeline . QueueCommand ( r => r . Type ( key ) , x => keyTypes [ key ] = x ) ) ;
34
+
35
+ pipeline . Flush ( ) ;
36
+ }
37
+
38
+ Assert . That ( RedisNativeClient . RequestsPerHour , Is . EqualTo ( reqCount + 2 ) ) ;
39
+ Assert . That ( keyTypes . Count , Is . EqualTo ( map . Count ) ) ;
40
+ }
41
+ }
42
+ }
Original file line number Diff line number Diff line change 250
250
<Compile Include =" RedisPubSubServerTests.cs" />
251
251
<Compile Include =" RedisPubSubTests.cs" />
252
252
<Compile Include =" RedisScanTests.cs" />
253
+ <Compile Include =" RedisStatsTests.cs" />
253
254
<Compile Include =" RedisTransactionCommonTests.cs" />
254
255
<Compile Include =" RedisTransactionTests.cs" />
255
256
<Compile Include =" RedisUtilTests.cs" />
You can’t perform that action at this time.
0 commit comments