Skip to content
Permalink
Browse files

Replace usage of Keys with ScanAllKeys()

  • Loading branch information...
mythz committed Aug 8, 2019
1 parent 71c4b9e commit 045af32014e9eccd6dc09d8ad748ef6041e7c1cc
@@ -412,8 +412,8 @@ public IRedisPipeline CreatePipeline()

public List<string> SearchKeys(string pattern)
{
var multiDataList = Keys(pattern);
return multiDataList.ToStringList();
var multiDataList = ScanAllKeys(pattern);
return multiDataList.ToList();
}

public List<string> GetValues(List<string> keys)
@@ -961,7 +961,7 @@ public string LoadLuaScript(string body)

public void RemoveByPattern(string pattern)
{
var keys = Keys(pattern).ToStringArray();
var keys = ScanAllKeys(pattern).ToArray();
if (keys.Length > 0)
Del(keys);
}
@@ -181,8 +181,7 @@ public void RemoveByPattern(string pattern)
{
using (var client = GetClient())
{
var redisClient = client as IRemoveByPattern;
if (redisClient != null)
if (client is IRemoveByPattern redisClient)
{
redisClient.RemoveByPattern(pattern);
}
@@ -193,8 +192,7 @@ public void RemoveByRegex(string pattern)
{
using (var client = GetClient())
{
var redisClient = client as IRemoveByPattern;
if (redisClient != null)
if (client is IRemoveByPattern redisClient)
{
redisClient.RemoveByRegex(pattern);
}
@@ -205,8 +203,7 @@ public void RemoveByRegex(string pattern)
{
using (var client = GetClient())
{
var redisClient = client as ICacheClientExtended;
if (redisClient != null)
if (client is ICacheClientExtended redisClient)
{
return redisClient.GetTimeToLive(key);
}
@@ -311,6 +311,9 @@ public void Can_get_Keys_with_pattern()

var keys = Redis.Keys("k1:*");
Assert.That(keys.Length, Is.EqualTo(5));

var scanKeys = Redis.ScanAllKeys("k1:*").ToArray();
Assert.That(scanKeys.Length, Is.EqualTo(5));
}

[Test]

0 comments on commit 045af32

Please sign in to comment.
You can’t perform that action at this time.