diff --git a/Blog.Core.Api/Blog.Core.Api.csproj b/Blog.Core.Api/Blog.Core.Api.csproj index 04b66117..441e19e7 100644 --- a/Blog.Core.Api/Blog.Core.Api.csproj +++ b/Blog.Core.Api/Blog.Core.Api.csproj @@ -3,6 +3,7 @@ Exe enable + true Linux true @@ -95,6 +96,9 @@ Always + + PreserveNewest + diff --git a/Blog.Core.Extensions/ServiceExtensions/CacheSetup.cs b/Blog.Core.Extensions/ServiceExtensions/CacheSetup.cs index c7b76f54..9966f5b5 100644 --- a/Blog.Core.Extensions/ServiceExtensions/CacheSetup.cs +++ b/Blog.Core.Extensions/ServiceExtensions/CacheSetup.cs @@ -8,6 +8,7 @@ using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; +using Serilog; using StackExchange.Redis; namespace Blog.Core.Extensions.ServiceExtensions; @@ -21,6 +22,7 @@ public static class CacheSetup public static void AddCacheSetup(this IServiceCollection services) { var cacheOptions = App.GetOptions(); + Console.WriteLine("RedisOptions:{0}", cacheOptions.ToJson()); if (cacheOptions.Enable) { // 配置启动Redis服务,虽然可能影响项目启动速度,但是不能在运行的时候报错,所以是合理的 @@ -35,7 +37,8 @@ public static void AddCacheSetup(this IServiceCollection services) //使用Redis services.AddStackExchangeRedisCache(options => { - options.ConnectionMultiplexerFactory = () => Task.FromResult(App.GetService(false)); + options.ConnectionMultiplexerFactory = + () => Task.FromResult(App.GetService(false)); if (!cacheOptions.InstanceName.IsNullOrEmpty()) options.InstanceName = cacheOptions.InstanceName; });