diff --git a/DragaliaAPI/DragaliaAPI/DragaliaAPI.csproj b/DragaliaAPI/DragaliaAPI/DragaliaAPI.csproj
index d0b374bcb..c9ca756c0 100644
--- a/DragaliaAPI/DragaliaAPI/DragaliaAPI.csproj
+++ b/DragaliaAPI/DragaliaAPI/DragaliaAPI.csproj
@@ -48,6 +48,7 @@
+
diff --git a/DragaliaAPI/DragaliaAPI/Program.cs b/DragaliaAPI/DragaliaAPI/Program.cs
index 6b42061ab..199c6d1eb 100644
--- a/DragaliaAPI/DragaliaAPI/Program.cs
+++ b/DragaliaAPI/DragaliaAPI/Program.cs
@@ -26,6 +26,7 @@
using Microsoft.FeatureManagement;
using Microsoft.JSInterop;
using Serilog;
+using StackExchange.Redis;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
@@ -70,9 +71,14 @@
builder.Services.ConfigureDatabaseServices(builder.Configuration);
+IConnectionMultiplexer multiplexer = ConnectionMultiplexer.Connect(
+ builder.Configuration.GetConnectionString("redis")
+ ?? throw new InvalidOperationException("Missing redis connection string!")
+);
+builder.Services.AddSingleton(multiplexer);
builder.Services.AddStackExchangeRedisCache(options =>
{
- options.Configuration = builder.Configuration.GetConnectionString("redis");
+ options.ConnectionMultiplexerFactory = () => Task.FromResult(multiplexer);
options.InstanceName = "RedisInstance";
});
diff --git a/DragaliaAPI/DragaliaAPI/ServiceConfiguration.cs b/DragaliaAPI/DragaliaAPI/ServiceConfiguration.cs
index 5eb583331..6d53710a3 100644
--- a/DragaliaAPI/DragaliaAPI/ServiceConfiguration.cs
+++ b/DragaliaAPI/DragaliaAPI/ServiceConfiguration.cs
@@ -275,11 +275,11 @@ public static WebApplicationBuilder ConfigureObservability(this WebApplicationBu
cfg.AddService(serviceName: "dragalia-api", autoGenerateServiceInstanceId: false);
})
.WithTracing(tracing =>
- tracing.AddEntityFrameworkCoreInstrumentation(options =>
- options.SetDbStatementForText = true
- )
- // Not compatible with IDistributedCache as requires IConnectionMultiplexer
- // .AddRedisInstrumentation()
+ tracing
+ .AddEntityFrameworkCoreInstrumentation(options =>
+ options.SetDbStatementForText = true
+ )
+ .AddRedisInstrumentation()
);
return builder;