Commit 3e9fee8b authored by Marc Gravell's avatar Marc Gravell

RawResult - when parsing, don't over-allocate the scratch buffer used for the parse

parent 7c709ecf
...@@ -8,8 +8,9 @@ internal static class Program ...@@ -8,8 +8,9 @@ internal static class Program
{ {
public static async Task Main() public static async Task Main()
{ {
using (var conn = await ConnectionMultiplexer.ConnectAsync("127.0.0.1:6379")) using (var conn = await ConnectionMultiplexer.ConnectAsync("127.0.0.1:6379,syncTimeout=2000"))
{ {
conn.ConnectionFailed += (sender, e) => Console.WriteLine($"{e.ConnectionType}, {e.FailureType}: {e.Exception.Message}");
var db = conn.GetDatabase(3); var db = conn.GetDatabase(3);
var batch = db.CreateBatch(); var batch = db.CreateBatch();
...@@ -29,10 +30,11 @@ public static async Task Main() ...@@ -29,10 +30,11 @@ public static async Task Main()
for (int i = 0; i < 1000; i++) for (int i = 0; i < 1000; i++)
{ {
int x = rand.Next(50); int x = rand.Next(50);
Console.WriteLine($"{i}:{x}");
expected += x; expected += x;
db.StringIncrement(counter, x, CommandFlags.FireAndForget); db.StringIncrement(counter, x); //, CommandFlags.FireAndForget);
} }
int actual = (int)db.StringGet(counter); int actual = (int)await db.StringGetAsync(counter);
Console.WriteLine($"{expected} vs {actual}"); Console.WriteLine($"{expected} vs {actual}");
} }
} }
......
...@@ -373,7 +373,7 @@ internal bool TryGetInt64(out long value) ...@@ -373,7 +373,7 @@ internal bool TryGetInt64(out long value)
if (_payload.IsSingleSegment) return RedisValue.TryParseInt64(_payload.First.Span, out value); if (_payload.IsSingleSegment) return RedisValue.TryParseInt64(_payload.First.Span, out value);
Span<byte> span = stackalloc byte[PhysicalConnection.MaxInt64TextLen]; Span<byte> span = stackalloc byte[(int)_payload.Length]; // we already checked the length was <= MaxInt64TextLen
_payload.CopyTo(span); _payload.CopyTo(span);
return RedisValue.TryParseInt64(span, out value); return RedisValue.TryParseInt64(span, out value);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment