Skip to content
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
61bc425
Improves Redis cache list retrieval performance
niemyjski Oct 21, 2025
df68571
Improves Redis cache list retrieval performance.
niemyjski Oct 21, 2025
cb640e0
Remove comment
niemyjski Oct 21, 2025
9aa8e42
.NET 8 improvements
niemyjski Nov 6, 2025
58863a2
Adds GetAllExpiration and SetAllExpiration
niemyjski Nov 6, 2025
97bb8c2
Updated redis tests
niemyjski Nov 18, 2025
dfea977
Updated tests
niemyjski Nov 22, 2025
cc78a63
Guards against null/empty cache keys
niemyjski Nov 22, 2025
bb6f286
cleanup
niemyjski Nov 22, 2025
ae446f1
Guards against null or empty cache keys
niemyjski Nov 22, 2025
8567269
Improves GetAllAsync input validation
niemyjski Nov 22, 2025
98bad3e
Improves Redis cache key deletion efficiency.
niemyjski Nov 22, 2025
e926d43
Adds argument null check to SetAllAsync
niemyjski Nov 22, 2025
88705dd
Clarifies Redis cache parallelism limits
niemyjski Nov 25, 2025
1dad2cd
feat(cache): Optimize SetAllAsync with MSET/MSETEX batch operations
niemyjski Nov 25, 2025
f4764ef
Improves GetAllExpiration logic
niemyjski Nov 25, 2025
298f04a
PR Feedback
niemyjski Nov 25, 2025
0f11e24
Updated test coverage
niemyjski Nov 27, 2025
43a1a87
Updated to foundatio nightly
niemyjski Nov 27, 2025
ff93427
Updates test and benchmark dependencies
niemyjski Nov 27, 2025
46fe65e
Updates exception type for script result mismatch
niemyjski Nov 27, 2025
afb5238
Adds expiration validation tests
niemyjski Nov 27, 2025
230303f
Improves Redis cache expiration handling
niemyjski Nov 27, 2025
1cfae4a
Updates Foundatio package versions
niemyjski Nov 27, 2025
f5f1afd
Reverted some .net 8 changes, these can be in a follow up pr.
niemyjski Nov 28, 2025
c29daf5
Reverted some .NET 8 async changes that could change the runtime beha…
niemyjski Nov 28, 2025
625c02f
Merge remote-tracking branch 'origin/main' into feature/get-set-all-e…
niemyjski Nov 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Foundatio.Xunit" Version="12.0.0" />
<PackageReference Include="Foundatio.Xunit" Version="12.0.1-alpha.0.22" />
</ItemGroup>

<ItemGroup>
Expand Down
657 changes: 510 additions & 147 deletions src/Foundatio.Redis/Cache/RedisCacheClient.cs

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/Foundatio.Redis/Cache/RedisHybridCacheClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class RedisHybridCacheClientOptions : RedisCacheClientOptions
public class RedisHybridCacheClientOptionsBuilder :
SharedOptionsBuilder<RedisHybridCacheClientOptions, RedisHybridCacheClientOptionsBuilder>
{

public RedisHybridCacheClientOptionsBuilder ConnectionMultiplexer(IConnectionMultiplexer connectionMultiplexer)
{
Target.ConnectionMultiplexer = connectionMultiplexer;
Expand Down
35 changes: 0 additions & 35 deletions src/Foundatio.Redis/Extensions/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,6 @@ namespace Foundatio.Redis.Extensions;

internal static class EnumerableExtensions
{
public static IEnumerable<T[]> Batch<T>(
this IEnumerable<T> source,
int batchSize)
{
if (source == null) throw new ArgumentNullException(nameof(source));
if (batchSize <= 0) throw new ArgumentOutOfRangeException(nameof(batchSize));

using var e = source.GetEnumerator();
while (true)
{
// allocate one buffer for this batch
var buffer = new T[batchSize];
int count = 0;

while (count < batchSize && e.MoveNext())
buffer[count++] = e.Current;

if (count == 0)
yield break;

if (count == batchSize)
{
yield return buffer;
}
else
{
// final partial batch: copy to a right-sized array
var tail = new T[count];
Array.Copy(buffer, tail, count);
yield return tail;
yield break;
}
}
}

public static async IAsyncEnumerable<T[]> BatchAsync<T>(
this IAsyncEnumerable<T> source,
int batchSize,
Expand Down
3 changes: 1 addition & 2 deletions src/Foundatio.Redis/Extensions/TypeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Foundatio.Utility;

namespace Foundatio.Extensions;
Expand Down Expand Up @@ -42,7 +42,6 @@ public static bool IsNumeric(this Type type)
return false;
}


public static bool IsNullableNumeric(this Type type)
{
if (type.IsArray)
Expand Down
4 changes: 2 additions & 2 deletions src/Foundatio.Redis/Foundatio.Redis.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\common.props" />
<ItemGroup>
<PackageReference Include="Foundatio" Version="12.0.0" Condition="'$(ReferenceFoundatioSource)' == '' OR '$(ReferenceFoundatioSource)' == 'false'" />
<PackageReference Include="Foundatio" Version="12.0.1-alpha.0.22" Condition="'$(ReferenceFoundatioSource)' == '' OR '$(ReferenceFoundatioSource)' == 'false'" />
<ProjectReference Include="..\..\..\Foundatio\src\Foundatio\Foundatio.csproj" Condition="'$(ReferenceFoundatioSource)' == 'true'" />

<PackageReference Include="StackExchange.Redis" Version="2.9.32" />
<PackageReference Include="StackExchange.Redis" Version="2.10.1" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Scripts\*.lua" />
Expand Down
15 changes: 15 additions & 0 deletions src/Foundatio.Redis/Scripts/GetAllExpiration.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Get expiration times for multiple keys
-- KEYS: All keys to check expiration for
-- Returns: Array of TTL values in milliseconds (in same order as KEYS)
-- Returns -2 for non-existent keys
-- Returns -1 for keys without expiration
-- Returns positive number for keys with expiration

local result = {}

for i = 1, #KEYS do
local ttl = redis.call('pttl', KEYS[i])
table.insert(result, ttl)
end

return result
17 changes: 17 additions & 0 deletions src/Foundatio.Redis/Scripts/SetAllExpiration.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- Set expiration times for multiple keys
-- KEYS: All keys to set expiration for
-- ARGV: TTL values in milliseconds corresponding to each key in KEYS
-- Use -1 or 0 to remove expiration (persist)
-- Positive values set the expiration

for i = 1, #KEYS do
local ttl = tonumber(ARGV[i])

if ttl == nil or ttl <= 0 then
redis.call('persist', KEYS[i])
else
redis.call('pexpire', KEYS[i], math.ceil(ttl))
end
end

return true
4 changes: 2 additions & 2 deletions tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1" PrivateAssets="All" />
<PackageReference Include="GitHubActionsTestLogger" Version="3.0.1" PrivateAssets="All" />

<PackageReference Include="Foundatio.TestHarness" Version="12.0.0" Condition="'$(ReferenceFoundatioSource)' == '' OR '$(ReferenceFoundatioSource)' == 'false'" />
<PackageReference Include="Foundatio.TestHarness" Version="12.0.1-alpha.0.22" Condition="'$(ReferenceFoundatioSource)' == '' OR '$(ReferenceFoundatioSource)' == 'false'" />
<ProjectReference Include="..\..\..\Foundatio\src\Foundatio.TestHarness\Foundatio.TestHarness.csproj" Condition="'$(ReferenceFoundatioSource)' == 'true'" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion tests/Foundatio.Benchmarks/Foundatio.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<ProjectReference Include="..\..\src\Foundatio.Redis\Foundatio.Redis.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.15.4" />
<PackageReference Include="BenchmarkDotNet" Version="0.15.6" />
</ItemGroup>
</Project>
Loading
Loading