diff --git a/MP.Core/Utils.cs b/MP.Core/Utils.cs index 07d3d6f9..6d978777 100644 --- a/MP.Core/Utils.cs +++ b/MP.Core/Utils.cs @@ -17,6 +17,7 @@ namespace MP.Core public const string redisArtList = redisBaseAddr + "Cache:ArtList"; public const string redisBaseAddr = "MP:"; public const string redisConfFlux = redisBaseAddr + "Cache:ConfFlux"; + public const string redisConfAll = redisBaseAddr + "Cache:ConfigAll"; public const string redisConfKey = redisBaseAddr + "Cache:Config"; public const string redisDecNumArtKey = redisBaseAddr + "Cache:DecNumArt"; public const string redisDossByMac = redisBaseAddr + "Cache:DossByMac"; diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index cab5679e..844322fd 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -34,7 +34,8 @@ namespace MP.SPEC.Data redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis") ?? "localhost:6379"); redisConnAdmin = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("RedisAdmin") ?? "localhost:6379"); redisDb = redisConn.GetDatabase(); - // leggo cache lungo periodo + // leggo cache lungo/cordo periodo + int.TryParse(_configuration.GetValue("ServerConf:redisShortTimeCache"), out redisShortTimeCache); int.TryParse(_configuration.GetValue("ServerConf:redisLongTimeCache"), out redisLongTimeCache); // setup MsgPipe @@ -410,7 +411,7 @@ namespace MP.SPEC.Data string source = "REDIS"; List? result = new List(); // cerco in redis... - RedisValue rawData = redisDb.StringGet(Utils.redisConfKey); + RedisValue rawData = redisDb.StringGet($"{Utils.redisConfKey}_sync"); if (!string.IsNullOrEmpty($"{rawData}")) { result = JsonConvert.DeserializeObject>($"{rawData}"); @@ -421,7 +422,7 @@ namespace MP.SPEC.Data result = dbController.ConfigGetAll(); // serializzo e salvo... rawData = JsonConvert.SerializeObject(result); - redisDb.StringSet(Utils.redisConfKey, rawData, getRandTOut(redisLongTimeCache)); + redisDb.StringSet($"{Utils.redisConfKey}_sync", rawData, getRandTOut(redisLongTimeCache)); } if (result == null) { @@ -442,10 +443,10 @@ namespace MP.SPEC.Data { return await GetOrFetchAsync( operationName: "ConfigGetAllAsync", - cacheKey: Utils.redisConfKey, - expiration: getRandTOut(redisLongTimeCache), + cacheKey: Utils.redisConfAll, + expiration: getRandTOut(redisLongTimeCache * 2), fetchFunc: async () => await dbController.ConfigGetAllAsync() ?? new List(), - tagList: [Utils.redisConfKey] + tagList: [Utils.redisConfAll] ); } diff --git a/MP.SPEC/appsettings.Development.json b/MP.SPEC/appsettings.Development.json index de8e232d..8c2753ce 100644 --- a/MP.SPEC/appsettings.Development.json +++ b/MP.SPEC/appsettings.Development.json @@ -14,7 +14,6 @@ "ServerConf": { "maxAge": "2000", "cacheCheckArtUsato": 2, - "redisLongTimeCache": 15, "MpIoBaseUrl": "https://iis01.egalware.com/MP/IO/" } } diff --git a/MP.SPEC/appsettings.Production.json b/MP.SPEC/appsettings.Production.json index 07c7752c..1424dd3f 100644 --- a/MP.SPEC/appsettings.Production.json +++ b/MP.SPEC/appsettings.Production.json @@ -27,7 +27,8 @@ "ServerConf": { "maxAge": "2000", "cacheCheckArtUsato": 2, - "redisLongTimeCache": 15, + "redisShortTimeCache": 10, + "redisLongTimeCache": 600, "MpIoBaseUrl": "http://localhost/MP/IO/", "MpIoNS": "MoonPro:SQL2016DEV:MoonPro", "BasePathOdlReturn": "\\\\iis01\\W$\\Files\\ODL", diff --git a/MP.SPEC/appsettings.Staging.json b/MP.SPEC/appsettings.Staging.json index d61f5682..531d2258 100644 --- a/MP.SPEC/appsettings.Staging.json +++ b/MP.SPEC/appsettings.Staging.json @@ -14,7 +14,6 @@ "ServerConf": { "maxAge": "2000", "cacheCheckArtUsato": 2, - "redisLongTimeCache": 15, "MpIoBaseUrl": "http://localhost/MP/IO/" } } diff --git a/MP.SPEC/appsettings.json b/MP.SPEC/appsettings.json index 712e6fcb..ff3e5c10 100644 --- a/MP.SPEC/appsettings.json +++ b/MP.SPEC/appsettings.json @@ -68,7 +68,8 @@ "ServerConf": { "maxAge": "2000", "cacheCheckArtUsato": "2", - "redisLongTimeCache": "15", + "redisShortTimeCache": 5, + "redisLongTimeCache": 120, "MpIoBaseUrl": "http://localhost:20967/", "MpIoNS": "MoonPro:SQL2016DEV:MoonPro", "BasePathOdlReturn": "\\\\iis01\\ODL\\ftpdata\\syncfolder",