This commit is contained in:
parent
356bb074d5
commit
f8cf88cbe1
|
|
@ -14,9 +14,15 @@ namespace ZR.Common.Cache
|
|||
Cache = new CSRedisClient(AppSettings.GetConfig("RedisServer:Cache"));
|
||||
Session = new CSRedisClient(AppSettings.GetConfig("RedisServer:Session"));
|
||||
var webApiCacheConfig = AppSettings.GetConfig("RedisServer:WebApiCache");
|
||||
Console.WriteLine($"[RedisServer] WebApiCache配置: [{webApiCacheConfig ?? "(null)"}]");
|
||||
if (!string.IsNullOrEmpty(webApiCacheConfig))
|
||||
{
|
||||
WebApiCache = new CSRedisClient(webApiCacheConfig);
|
||||
Console.WriteLine("[RedisServer] WebApiCache已初始化");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("[RedisServer] 警告: WebApiCache未配置,清空送花缓存功能将不可用");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,32 +164,15 @@ namespace ZR.Service.Liveforum
|
|||
{
|
||||
var logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
// 按需获取WebAPI Redis连接,不依赖启动时初始化
|
||||
var webApiRedis = RedisServer.WebApiCache;
|
||||
if (webApiRedis == null)
|
||||
{
|
||||
var config = Infrastructure.AppSettings.GetConfig("RedisServer:WebApiCache");
|
||||
logger.Info("RedisServer:WebApiCache 配置值: [{0}], IsNull: {1}, IsEmpty: {2}",
|
||||
config ?? "(null)", config == null, string.IsNullOrEmpty(config));
|
||||
|
||||
// 打印其他Redis配置做对比
|
||||
var cacheConfig = Infrastructure.AppSettings.GetConfig("RedisServer:Cache");
|
||||
var openConfig = Infrastructure.AppSettings.GetConfig("RedisServer:open");
|
||||
logger.Info("RedisServer:Cache 配置值: [{0}]", cacheConfig ?? "(null)");
|
||||
logger.Info("RedisServer:open 配置值: [{0}]", openConfig ?? "(null)");
|
||||
|
||||
if (string.IsNullOrEmpty(config))
|
||||
{
|
||||
throw new Exception($"WebAPI Redis未配置。RedisServer:open=[{openConfig}], RedisServer:Cache=[{(string.IsNullOrEmpty(cacheConfig) ? "(空)" : "已配置")}], RedisServer:WebApiCache=[(空)]。请在appsettings.json的RedisServer节点下添加WebApiCache配置项");
|
||||
}
|
||||
|
||||
logger.Info("正在创建WebAPI Redis连接: {0}", config);
|
||||
webApiRedis = new CSRedis.CSRedisClient(config);
|
||||
RedisServer.WebApiCache = webApiRedis;
|
||||
logger.Error("RedisServer.WebApiCache 为 null,请检查:1) appsettings.json 中是否配置了 RedisServer:WebApiCache 2) 配置后是否重启了服务");
|
||||
throw new Exception("WebAPI Redis未初始化。请确认appsettings.json中已配置RedisServer:WebApiCache,并重启管理后台服务");
|
||||
}
|
||||
|
||||
var keys = webApiRedis.Keys("flower_count:Streamer:*");
|
||||
logger.Info("找到 {0} 个flower_count:Streamer:* 缓存key", keys?.Length ?? 0);
|
||||
logger.Info("找到 {0} 个 flower_count:Streamer:* 缓存key", keys?.Length ?? 0);
|
||||
|
||||
if (keys == null || keys.Length == 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user