Skip to content

Commit e732b7f

Browse files
authored
set initial client info with first 'transaction' creation (#290)
1 parent 26ff438 commit e732b7f

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

src/NRedisStack/Auxiliary.cs

+11-13
Original file line numberDiff line numberDiff line change
@@ -48,30 +48,28 @@ public static IDatabase GetDatabase(this ConnectionMultiplexer redis,
4848
return _db;
4949
}
5050

51-
private static void SetInfoInPipeline(this IDatabase db)
51+
internal static void SetInfoInPipeline(this IDatabase db)
5252
{
53-
if (_libraryName == null) return;
54-
Pipeline pipeline = new Pipeline(db);
55-
_ = pipeline.Db.ClientSetInfoAsync(SetInfoAttr.LibraryName, _libraryName!);
56-
_ = pipeline.Db.ClientSetInfoAsync(SetInfoAttr.LibraryVersion, GetNRedisStackVersion());
57-
pipeline.Execute();
53+
if (_setInfo)
54+
{
55+
_setInfo = false;
56+
if (_libraryName == null) return;
57+
Pipeline pipeline = new Pipeline(db);
58+
_ = pipeline.Db.ClientSetInfoAsync(SetInfoAttr.LibraryName, _libraryName!);
59+
_ = pipeline.Db.ClientSetInfoAsync(SetInfoAttr.LibraryVersion, GetNRedisStackVersion());
60+
pipeline.Execute();
61+
}
5862
}
5963

6064
public static RedisResult Execute(this IDatabase db, SerializedCommand command)
6165
{
62-
if (!_setInfo) return db.Execute(command.Command, command.Args);
63-
_setInfo = false;
6466
db.SetInfoInPipeline();
6567
return db.Execute(command.Command, command.Args);
6668
}
6769

6870
public static async Task<RedisResult> ExecuteAsync(this IDatabaseAsync db, SerializedCommand command)
6971
{
70-
if (_setInfo)
71-
{
72-
_setInfo = false;
73-
((IDatabase)db).SetInfoInPipeline();
74-
}
72+
((IDatabase)db).SetInfoInPipeline();
7573
return await db.ExecuteAsync(command.Command, command.Args);
7674
}
7775

src/NRedisStack/Transactions.cs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class Transaction
99

1010
public Transaction(IDatabase db)
1111
{
12+
db.SetInfoInPipeline();
1213
_transaction = db.CreateTransaction();
1314
}
1415

0 commit comments

Comments
 (0)