From 895b54beb7d1b09d5e579a705f17a135d5f80491 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 29 Apr 2022 18:45:47 +0200 Subject: [PATCH] =?UTF-8?q?Cache=20x=20ottimizzazione=20velocit=C3=A0=20ac?= =?UTF-8?q?cesso=20pagina=20articoli?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WebUserControls/mod_anagArticoli.ascx.cs | 31 +++++++++++++------ MP-IO/MP-IO.csproj.user | 2 +- MP-MAG/MP-MAG.csproj | 6 ---- MP-MAG/packages.config | 3 -- MP-Site/MP-Site.csproj.user | 2 +- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/MP-ADM/WebUserControls/mod_anagArticoli.ascx.cs b/MP-ADM/WebUserControls/mod_anagArticoli.ascx.cs index 88b15cc1..a277b156 100644 --- a/MP-ADM/WebUserControls/mod_anagArticoli.ascx.cs +++ b/MP-ADM/WebUserControls/mod_anagArticoli.ascx.cs @@ -1,4 +1,5 @@ -using SteamWare; +using MapoDb; +using SteamWare; using System; using System.Data; using System.Web.UI.WebControls; @@ -9,19 +10,31 @@ namespace MP_ADM.WebUserControls { #region Public Methods + public bool delEnabled(object _idx) { bool answ = false; - string codArticolo = _idx.ToString(); - // controllo non sia stato mai prodotto sennò non posso cancellare... - try + string codArticolo = $"{_idx}"; + // cerco in cache redis... + string redKeyArtUsed = DataLayer.mHash($"CACHE:CheckArtUsed:{codArticolo}"); + string rawData = memLayer.ML.getRSV(redKeyArtUsed); + if (!string.IsNullOrEmpty(rawData)) { - bool? usato = false; - DataLayerObj.taAnagArt.checkUsed(codArticolo, ref usato); - answ = !(bool)usato; + bool.TryParse(rawData, out answ); + } + else + { + // controllo non sia stato mai prodotto sennò non posso cancellare... + try + { + bool? usato = false; + DataLayerObj.taAnagArt.checkUsed(codArticolo, ref usato); + answ = !(bool)usato; + memLayer.ML.setRSV(redKeyArtUsed, $"{answ}", 60 * memLayer.ML.cdvi("cacheCheckArtUsato")); + } + catch + { } } - catch - { } return answ; } diff --git a/MP-IO/MP-IO.csproj.user b/MP-IO/MP-IO.csproj.user index 391097c4..e85dec40 100644 --- a/MP-IO/MP-IO.csproj.user +++ b/MP-IO/MP-IO.csproj.user @@ -10,7 +10,7 @@ - Release|Any CPU + Debug|Any CPU MvcControllerEmptyScaffolder root/Common/MVC/Controller 600 diff --git a/MP-MAG/MP-MAG.csproj b/MP-MAG/MP-MAG.csproj index 8d0588b9..0ff62f72 100644 --- a/MP-MAG/MP-MAG.csproj +++ b/MP-MAG/MP-MAG.csproj @@ -59,9 +59,6 @@ ..\packages\AspNet.ScriptManager.jQuery.3.6.0\lib\net45\AspNet.ScriptManager.jQuery.dll - - ..\packages\Crc32C.NET.1.0.5.0\lib\net20\Crc32C.NET.dll - ..\packages\DnsClient.1.6.0\lib\net45\DnsClient.dll @@ -126,9 +123,6 @@ ..\packages\SharpCompress.0.31.0\lib\net461\SharpCompress.dll - - ..\packages\Snappy.NET.1.1.1.8\lib\net45\Snappy.NET.dll - ..\packages\StackExchange.Redis.2.5.61\lib\net461\StackExchange.Redis.dll diff --git a/MP-MAG/packages.config b/MP-MAG/packages.config index 7ab9a81f..37e9e158 100644 --- a/MP-MAG/packages.config +++ b/MP-MAG/packages.config @@ -6,7 +6,6 @@ - @@ -22,7 +21,6 @@ - @@ -52,7 +50,6 @@ - diff --git a/MP-Site/MP-Site.csproj.user b/MP-Site/MP-Site.csproj.user index 3679bec0..c2cb7f33 100644 --- a/MP-Site/MP-Site.csproj.user +++ b/MP-Site/MP-Site.csproj.user @@ -8,7 +8,7 @@ - Release|Any CPU + Debug|Any CPU ShowAllFiles IIS02