From 8b64a53260b1c95d8c22be45ab7d1990316ddc01 Mon Sep 17 00:00:00 2001 From: Chris Pinola Date: Thu, 10 Sep 2020 02:15:22 -0400 Subject: [PATCH] Implement KeyValuePairParser.TryRead for Int64 (#1568) --- src/StackExchange.Redis/ResultProcessor.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/StackExchange.Redis/ResultProcessor.cs b/src/StackExchange.Redis/ResultProcessor.cs index afacd9e83..924f24b4c 100644 --- a/src/StackExchange.Redis/ResultProcessor.cs +++ b/src/StackExchange.Redis/ResultProcessor.cs @@ -1550,7 +1550,8 @@ protected override StreamConsumerInfo ParseItem(in RawResult result) var arr = result.GetItems(); string name = default; - int pendingMessageCount = default, idleTimeInMilliseconds = default; + int pendingMessageCount = default; + long idleTimeInMilliseconds = default; KeyValuePairParser.TryRead(arr, KeyValuePairParser.Name, ref name); KeyValuePairParser.TryRead(arr, KeyValuePairParser.Pending, ref pendingMessageCount); @@ -1566,20 +1567,30 @@ internal static readonly CommandBytes Name = "name", Consumers = "consumers", Pending = "pending", Idle = "idle", LastDeliveredId = "last-delivered-id", IP = "ip", Port = "port"; - internal static bool TryRead(Sequence pairs, in CommandBytes key, ref int value) + internal static bool TryRead(Sequence pairs, in CommandBytes key, ref long value) { var len = pairs.Length / 2; for (int i = 0; i < len; i++) { if (pairs[i * 2].IsEqual(key) && pairs[(i * 2) + 1].TryGetInt64(out var tmp)) { - value = checked((int)tmp); + value = tmp; return true; } } return false; } + internal static bool TryRead(Sequence pairs, in CommandBytes key, ref int value) + { + long tmp = default; + if(TryRead(pairs, key, ref tmp)) { + value = checked((int)tmp); + return true; + } + return false; + } + internal static bool TryRead(Sequence pairs, in CommandBytes key, ref string value) { var len = pairs.Length / 2;