Skip to content

Commit

Permalink
Updated RemoveByPrefix and added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
niemyjski committed Sep 27, 2024
1 parent 0541a55 commit 64e953f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Foundatio.Redis/Cache/RedisCacheClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public async Task<int> RemoveAllAsync(IEnumerable<string> keys = null)
public async Task<int> RemoveByPrefixAsync(string prefix)
{
const int chunkSize = 2500;
string regex = $"{prefix}*";
string normalizedPrefix = String.IsNullOrWhiteSpace(prefix) ? "*" : prefix.Trim();
string regex = normalizedPrefix.Contains("*") ? normalizedPrefix : $"{normalizedPrefix}*";

int total = 0;
int index = 0;
Expand Down
6 changes: 6 additions & 0 deletions tests/Foundatio.Redis.Tests/Caching/RedisCacheClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ public override Task CanRemoveByPrefixAsync()
return base.CanRemoveByPrefixAsync();
}

[Fact]
public override Task CanRemoveByPrefixWithScopedCachesAsync()
{
return base.CanRemoveByPrefixWithScopedCachesAsync();
}

[Theory]
[InlineData(50)]
[InlineData(500)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public override Task CanRemoveByPrefixAsync()
return base.CanRemoveByPrefixAsync();
}

[Fact]
public override Task CanRemoveByPrefixWithScopedCachesAsync()
{
return base.CanRemoveByPrefixWithScopedCachesAsync();
}

[Theory]
[InlineData(50)]
[InlineData(500)]
Expand Down

0 comments on commit 64e953f

Please sign in to comment.