Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit dcc88f1

Browse files
committed
Add new RedisStats.TotalCommandsSent
1 parent cdb26de commit dcc88f1

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/ServiceStack.Redis/RedisNativeClient_Utils.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,8 @@ protected T SendReceive<T>(byte[][] cmdWithBinaryArgs,
500500
if (i > 0)
501501
Interlocked.Increment(ref RedisState.TotalRetrySuccess);
502502

503+
Interlocked.Increment(ref RedisState.TotalCommandsSent);
504+
503505
return result;
504506
}
505507
catch (Exception outerEx)

src/ServiceStack.Redis/RedisState.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ internal static class RedisState
1414
{
1515
private static ILog log = LogManager.GetLogger(typeof(RedisState));
1616

17+
internal static long TotalCommandsSent = 0;
1718
internal static long TotalFailovers = 0;
1819
internal static long TotalDeactivatedClients = 0;
1920
internal static long TotalFailedSentinelWorkers = 0;

src/ServiceStack.Redis/RedisStats.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ namespace ServiceStack.Redis
55
{
66
public static class RedisStats
77
{
8+
/// <summary>
9+
/// Total number of commands sent
10+
/// </summary>
11+
public static long TotalCommandsSent
12+
{
13+
get { return Interlocked.Read(ref RedisState.TotalCommandsSent); }
14+
}
15+
816
/// <summary>
917
/// Number of times the Redis Client Managers have FailoverTo() either by sentinel or manually
1018
/// </summary>
@@ -130,8 +138,9 @@ public static void Reset()
130138

131139
public static Dictionary<string, long> ToDictionary()
132140
{
133-
return new Dictionary<string, long>
141+
return new Dictionary<string, long>
134142
{
143+
{"TotalCommandsSent", TotalCommandsSent},
135144
{"TotalFailovers", TotalFailovers},
136145
{"TotalDeactivatedClients", TotalDeactivatedClients},
137146
{"TotalFailedSentinelWorkers", TotalFailedSentinelWorkers},

0 commit comments

Comments
 (0)