From a2d8779fc233067f4b9ec72c5e2d78f2cfe36be7 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 5 Dec 2018 22:07:15 +0100 Subject: [PATCH] Update gestione memLayer x cache appConf in REDIS --- Jenkinsfile | 2 +- SteamWareLib/memLayer.cs | 64 ++++++++++++++++++++++++++++++---------- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 114209c..c3a5506 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { steps { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=639']) { + withEnv(['NEXT_BUILD_NUMBER=640']) { // env.versionNumber = VersionNumber(versionNumberString : '3.2.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '3.2.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'SteamWareLib' diff --git a/SteamWareLib/memLayer.cs b/SteamWareLib/memLayer.cs index 1fe4c1a..64420b1 100644 --- a/SteamWareLib/memLayer.cs +++ b/SteamWareLib/memLayer.cs @@ -129,7 +129,9 @@ namespace SteamWare /// public void resetAppConf() { - redFlushKey(ACBH); +#if false + redFlushKey(ACBH); +#endif startupAppConf(); } /// @@ -160,14 +162,18 @@ namespace SteamWare valori[i] = new KeyValuePair(item.Key, item.Value); i++; } - redSaveHash(ACBH, valori); + // salvo in redis valori (con TTL) + redSaveHash(ACBH, valori, maxAgeAppConf); +#if false + redSaveHash(ACBH, valori); lastUpdateAppConf = DateTime.Now; +#endif logger.lg.scriviLog("Completato procedura startupAppConf ", tipoLog.INFO); } } catch (Exception exc) { - logger.lg.scriviLog(string.Format("Errore in startupAppConf:{0}{1}", Environment.NewLine, exc)); + logger.lg.scriviLog(string.Format("Errore in startupAppConf:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); } } } @@ -210,6 +216,7 @@ namespace SteamWare logger.lg.scriviLog(string.Format("Effettuata procedura ricaricaAppConf per {0} records", answ.Count), tipoLog.INFO); return answ; } +#if false /// /// ultimo update in cache dei valori di AppConfig /// @@ -230,7 +237,29 @@ namespace SteamWare setCacheVal("lastUpdateAppConf", value, true); } + } +#endif + /// + /// Recupera il TTL x appConf (secondi) + /// + public int maxAgeAppConf + { + get + { + // default 5 minuti x refresh... + int maxAge = 5; + try + { + maxAge = confReadInt("maxAgeAppConf_min"); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in lettura valore maxAgeAppConf_min{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + return maxAge * 60; + } } + /// /// Configurations da tabella DB Config /// @@ -253,6 +282,7 @@ namespace SteamWare { resetAppConf(); } +#if false // default 5 minuti x refresh... int maxAge = 5; try @@ -262,12 +292,14 @@ namespace SteamWare catch (Exception exc) { logger.lg.scriviLog(string.Format("Errore in lettura chiave [{0}] durante configDbVal{1}{2}", chiave, Environment.NewLine, exc), tipoLog.EXCEPTION); - } - // controllo SE � passato pi� di 5 minuti, nel caso faccio refresh... + } + // controllo SE sia passato piu di maxAge minuti, nel caso faccio refresh... if (DateTime.Now.Subtract(lastUpdateAppConf).TotalMinutes > maxAge) { + logger.lg.scriviLog(string.Format("Scaduta validita appConf --> reset! (lastUpdate: {0} | maxAge: {1})", lastUpdateAppConf, maxAge), tipoLog.EXCEPTION); resetAppConf(); } +#endif // provo a leggere da DICT try { @@ -1448,7 +1480,7 @@ namespace SteamWare } catch (Exception exc) { - logger.lg.scriviLog(string.Format("Errore in getRSV:{0}{1}", Environment.NewLine, exc)); + logger.lg.scriviLog(string.Format("Errore in getRSV:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); } return answ; } @@ -1468,7 +1500,7 @@ namespace SteamWare } catch (Exception exc) { - logger.lg.scriviLog(string.Format("Errore in setRSV:{0}{1}", Environment.NewLine, exc)); + logger.lg.scriviLog(string.Format("Errore in setRSV:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); } return answ; } @@ -1491,7 +1523,7 @@ namespace SteamWare } catch (Exception exc) { - logger.lg.scriviLog(string.Format("Errore in setRSV:{0}{1}", Environment.NewLine, exc)); + logger.lg.scriviLog(string.Format("Errore in setRSV:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); } return answ; } @@ -1509,7 +1541,7 @@ namespace SteamWare } catch (Exception exc) { - logger.lg.scriviLog(string.Format("Errore in setRCI:{0}{1}", Environment.NewLine, exc)); + logger.lg.scriviLog(string.Format("Errore in setRCI:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); } return answ; } @@ -1527,7 +1559,7 @@ namespace SteamWare } catch (Exception exc) { - logger.lg.scriviLog(string.Format("Errore in setRCD:{0}{1}", Environment.NewLine, exc)); + logger.lg.scriviLog(string.Format("Errore in setRCD:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); } return answ; } @@ -1547,7 +1579,7 @@ namespace SteamWare } catch (Exception exc) { - logger.lg.scriviLog(string.Format("Errore in getRSV:{0}{1}", Environment.NewLine, exc)); + logger.lg.scriviLog(string.Format("Errore in getRSV:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); } return answInt; } @@ -1565,7 +1597,7 @@ namespace SteamWare } catch (Exception exc) { - logger.lg.scriviLog(string.Format("Errore in resetRCnt:{0}{1}", Environment.NewLine, exc)); + logger.lg.scriviLog(string.Format("Errore in resetRCnt:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); } return answ; } @@ -1583,7 +1615,7 @@ namespace SteamWare } catch (Exception exc) { - logger.lg.scriviLog(string.Format("Errore in getRKeys:{0}{1}", Environment.NewLine, exc)); + logger.lg.scriviLog(string.Format("Errore in getRKeys:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); } return answ; } @@ -1602,7 +1634,7 @@ namespace SteamWare } catch (Exception exc) { - logger.lg.scriviLog(string.Format("Errore in setRKeys:{0}{1}", Environment.NewLine, exc)); + logger.lg.scriviLog(string.Format("Errore in setRKeys:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); } return answ; } @@ -1620,7 +1652,9 @@ namespace SteamWare answ = cache.HashGetAll(key).Length > 0; } catch (Exception exc) - { } + { + logger.lg.scriviLog(string.Format("Errore in redHashPresent per la key {2}:{0}{1}", Environment.NewLine, exc, key), tipoLog.EXCEPTION); + } return answ; } ///