From 633b5dda6e179283efb476ce6816ad31814ab90d Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 18 Oct 2022 09:51:43 +0200 Subject: [PATCH 1/3] Fix cache recupero ODL correnti (3 sec redis) --- MP.SPEC/Data/MpDataService.cs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index 2dd41035..73f64ab4 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -671,8 +671,34 @@ namespace MP.SPEC.Data /// public ODLModel OdlGetCurrentByMacc(string idxMacchina) { - // cache REDIS... - var dbResult = dbController.OdlGetCurrentByMacc(idxMacchina); + ODLModel dbResult = new ODLModel(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string readType = "DB"; + string currKey = $"{redisOdlCurrByMac}:{idxMacchina}"; + // cerco in redis dato valore sel macchina... + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + dbResult = JsonConvert.DeserializeObject($"{rawData}"); + readType = "REDIS"; + } + else + { + dbResult = dbController.OdlGetCurrentByMacc(idxMacchina); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(dbResult); + redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(3)); + } + if (dbResult == null) + { + dbResult = new ODLModel(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"OdlGetCurrentByMacc | Read from {readType}: {ts.TotalMilliseconds}ms"); + + return dbResult; } @@ -834,6 +860,7 @@ namespace MP.SPEC.Data private const string redisDossByMac = redisBaseAddr + "SPEC:Cache:DossByMac"; private const string redisFluxByMac = redisBaseAddr + "SPEC:Cache:FluxByMac"; + private const string redisOdlCurrByMac = redisBaseAddr + "SPEC:Cache:OdlByMac"; private const string redisMacByFlux = redisBaseAddr + "SPEC:Cache:MacByFlux"; private const string redisMacList = redisBaseAddr + "SPEC:Cache:MacList"; From 41a00ffa45ff33d14b862d0771dab74fb2f866d3 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Tue, 18 Oct 2022 09:55:29 +0200 Subject: [PATCH 2/3] fix 2 variabili x statRecord e currRecord --- MP.SPEC/Components/ListODL.razor | 54 ++++++++++++++--------------- MP.SPEC/Components/ListODL.razor.cs | 32 +++++++++++++---- MP.SPEC/MP.SPEC.csproj | 2 +- MP.SPEC/Resources/ChangeLog.html | 2 +- MP.SPEC/Resources/VersNum.txt | 2 +- MP.SPEC/Resources/manifest.xml | 2 +- MP.SPEC/wwwroot/lib/modalHandler.js | 35 +++++++------------ 7 files changed, 69 insertions(+), 60 deletions(-) diff --git a/MP.SPEC/Components/ListODL.razor b/MP.SPEC/Components/ListODL.razor index 8937c9d6..838f5857 100644 --- a/MP.SPEC/Components/ListODL.razor +++ b/MP.SPEC/Components/ListODL.razor @@ -110,7 +110,7 @@ else @record.DurataMinuti
- +
@@ -122,26 +122,26 @@ else