Skip to content

Commit 9bbcb13

Browse files
committed
Minor refactor to GlideClient.KeysAsync to improve performance by moving variable outside the loop.
Signed-off-by: currantw <[email protected]>
1 parent cdb4fe7 commit 9bbcb13

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sources/Valkey.Glide/GlideClient.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,17 @@ public async IAsyncEnumerable<ValkeyKey> KeysAsync(int database = -1, ValkeyValu
177177
{
178178
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
179179

180+
var options = new ScanOptions();
181+
if (!pattern.IsNull) options.MatchPattern = pattern.ToString();
182+
if (pageSize > 0) options.Count = pageSize;
183+
180184
string currentCursor = cursor.ToString();
185+
ValkeyKey[] keys;
181186
int currentOffset = pageOffset;
182187

183188
do
184189
{
185-
var options = new ScanOptions();
186-
if (!pattern.IsNull) options.MatchPattern = pattern.ToString();
187-
if (pageSize > 0) options.Count = pageSize;
188-
189-
(currentCursor, ValkeyKey[] keys) = await ScanAsync(currentCursor, options);
190+
(currentCursor, keys) = await ScanAsync(currentCursor, options);
190191

191192
if (currentOffset > 0)
192193
{

0 commit comments

Comments
 (0)