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

Commit 8b980d6

Browse files
committed
Use static ServerVersionNumber to cache the version once
1 parent 5b0d02d commit 8b980d6

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

src/ServiceStack.Redis/RedisNativeClient.cs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ public DateTime? DeactivatedAt
6868
private IRedisTransactionBase transaction;
6969
private IRedisPipelineShared pipeline;
7070

71-
private Dictionary<string, string> info;
72-
7371
const int YES = 1;
7472
const int NO = 0;
7573

@@ -246,21 +244,19 @@ public Dictionary<string, string> Info
246244
{
247245
get
248246
{
249-
if (this.info == null)
250-
{
251-
var lines = SendExpectString(Commands.Info);
252-
this.info = new Dictionary<string, string>();
247+
var lines = SendExpectString(Commands.Info);
248+
var info = new Dictionary<string, string>();
253249

254-
foreach (var line in lines
255-
.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries))
256-
{
257-
var p = line.IndexOf(':');
258-
if (p == -1) continue;
250+
foreach (var line in lines
251+
.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries))
252+
{
253+
var p = line.IndexOf(':');
254+
if (p == -1) continue;
259255

260-
this.info.Add(line.Substring(0, p), line.Substring(p + 1));
261-
}
256+
info.Add(line.Substring(0, p), line.Substring(p + 1));
262257
}
263-
return this.info;
258+
259+
return info;
264260
}
265261
}
266262

src/ServiceStack.Redis/RedisNativeClient_Utils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static int RequestsPerHour
3838
}
3939

4040
private const int Unknown = -1;
41-
public int ServerVersionNumber { get; set; }
41+
public static int ServerVersionNumber { get; set; }
4242

4343
public int AssertServerVersionNumber()
4444
{

0 commit comments

Comments
 (0)