Skip to content

Commit a80c251

Browse files
committed
handling client lib info changes by wrapping multiplxer creation
1 parent 519c9c2 commit a80c251

File tree

7 files changed

+2771
-5
lines changed

7 files changed

+2771
-5
lines changed

src/NRedisStack/Auxiliary.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ namespace NRedisStack;
66

77
public static class Auxiliary
88
{
9-
private static string? _libraryName = $"NRedisStack(.NET_v{Environment.Version})";
9+
private static string? _libraryName = $"NRedisStack-{GetNRedisStackVersion()}";
1010
private static bool _setInfo = true;
1111
public static void ResetInfoDefaults()
1212
{
1313
_setInfo = true;
14-
_libraryName = $"NRedisStack(.NET_v{Environment.Version})";
14+
_libraryName = $"NRedisStack-{GetNRedisStackVersion()}";
1515
}
1616
public static List<object> MergeArgs(RedisKey key, params RedisValue[] items)
1717
{
@@ -126,4 +126,7 @@ public static string GetNRedisStackVersion()
126126
Version version = typeof(Auxiliary).Assembly.GetName().Version!;
127127
return $"{version.Major}.{version.Minor}.{version.Build}";
128128
}
129+
130+
internal static string GetNRedisStackLibName() => _libraryName!;
131+
129132
}

src/NRedisStack/CoreCommands/CoreCommandsAsync.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@ public static class CoreCommandsAsync //: ICoreCommandsAsync
1515
/// <remarks><seealso href="https://redis.io/commands/client-setinfo/"/></remarks>
1616
public static async Task<bool> ClientSetInfoAsync(this IDatabaseAsync db, SetInfoAttr attr, string value)
1717
{
18-
var compareVersions = db.Multiplexer.GetServer(db.Multiplexer.GetEndPoints()[0]).Version.CompareTo(new Version(7, 1, 242));
19-
if (compareVersions < 0) // the server does not support the CLIENT SETNAME command
18+
IServer server = db.Multiplexer.GetServer(db.Multiplexer.GetEndPoints()[0]);
19+
return await server.ClientSetInfoAsync(attr, value);
20+
}
21+
22+
internal static async Task<bool> ClientSetInfoAsync(this IServer server, SetInfoAttr attr, string value)
23+
{
24+
var compareVersions = server.Version.CompareTo(new Version(7, 1, 242));
25+
if (compareVersions < 0) // the server does not support the CLIENT SETINFO command
2026
{
2127
return false;
2228
}
23-
return (await db.ExecuteAsync(CoreCommandBuilder.ClientSetInfo(attr, value))).OKtoBoolean();
29+
await server.Multiplexer.GetDatabase().ExecuteAsync(CoreCommandBuilder.ClientSetInfo(attr, value));
30+
var cmd = CoreCommandBuilder.ClientSetInfo(attr, value);
31+
return (await server.ExecuteAsync(cmd.Command, cmd.Args)).OKtoBoolean();
2432
}
2533

2634
/// <summary>

0 commit comments

Comments
 (0)