-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The SearchKeysAsync method does not behave as expected in the recent NuGet version 10.1.0. #586
Comments
first thanks for the feedback. The scan now is executed only on the servers that have been retrieved from the enumerate strategy. If u use the |
I even found this is true with 10.2.0 as well. Calling _redisClient.Db0.SearchKeysAsync("YourFirstKey") does return keys. But a second call _redisClient.Db0.SearchKeysAsync("YourSecondKey") returns no results. If I call _redisClient.ExecuteAsync("SCAN", 0, "MATCH", "YourSecondKey", "COUNT", "1000") before I _redisClient.Db0.SearchKeysAsync("YourSecondKey") they both return the expected results. |
Describe the bug
Update the StackExchange.Redis.Extensions.Core version from 9.1.0 to 10.1.0. However, the existing unit tests failed after the upgrade.
To Reproduce
Revert the NuGet package to version 9.1.0, debug the code to ascertain the count of keys matching a specific pattern, and confirm that it provides the accurate result. However, when using the newer version of the NuGet package, it consistently returns a count of 0 for keys matching the specified pattern.
Additional context
In the previous version 9.1.0, the code in RedisDatabase.cs at inside SearchKeysAsync method line 424 utilized the Database instance to execute a scan command:
var redisResult = await Database.ExecuteAsync("SCAN", nextCursor.ToString(), "MATCH", pattern, "COUNT", "1000").ConfigureAwait(false);
However, in the updated version, a modification is observed. Instead of using the Database instance, the code now employs an instance named unused within a loop iterating over servers:
var servers = ServerIteratorFactory
.GetServers(connectionPoolManager.GetConnection(), serverEnumerationStrategy)
.ToArray();
foreach (var unused in servers)
{
var redisResult = await unused.ExecuteAsync("SCAN", nextCursor.ToString(), "MATCH", pattern, "COUNT", "1000").ConfigureAwait(false);
// Additional code handling the redisResult may be present here.
}
The text was updated successfully, but these errors were encountered: