diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj
index b1390e67..a246b3c4 100644
--- a/MP.IOC/MP.IOC.csproj
+++ b/MP.IOC/MP.IOC.csproj
@@ -4,7 +4,7 @@
net8.0
enable
enable
- 8.16.2605.2811
+ 8.16.2605.2812
diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html
index 4f14e552..809025c0 100644
--- a/MP.IOC/Resources/ChangeLog.html
+++ b/MP.IOC/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MP-IOC
- Versione: 8.16.2605.2811
+ Versione: 8.16.2605.2812
Note di rilascio:
-
diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt
index 378864b8..5f877377 100644
--- a/MP.IOC/Resources/VersNum.txt
+++ b/MP.IOC/Resources/VersNum.txt
@@ -1 +1 @@
-8.16.2605.2811
+8.16.2605.2812
diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml
index 64384a3d..5e69e8ec 100644
--- a/MP.IOC/Resources/manifest.xml
+++ b/MP.IOC/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 8.16.2605.2811
+ 8.16.2605.2812
https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip
https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html
false
diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs
index 8d061509..2928da0e 100644
--- a/MP.SPEC/Data/MpDataService.cs
+++ b/MP.SPEC/Data/MpDataService.cs
@@ -1948,44 +1948,14 @@ namespace MP.SPEC.Data
///
public async Task POdlGetByOdlAsync(int idxODL)
{
- PODLModel result = new PODLModel();
- if (idxODL != 0)
- {
- using var activity = ActivitySource.StartActivity("POdlGetByOdlAsync");
- string source = "DB";
- string currKey = $"{Utils.redisPOdlByOdl}:{idxODL}";
- // cerco in redis dato valore sel idxMaccSel...
- RedisValue rawData = await redisDb.StringGetAsync(currKey);
- if (rawData.HasValue)
- {
- var rawResult = JsonConvert.DeserializeObject($"{rawData}");
- if (rawResult != null)
- {
- result = rawResult;
- }
- source = "REDIS";
- }
- else
- {
- result = await dbController.PODL_getByOdlAsync(idxODL);
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- await redisDb.StringSetAsync(currKey, rawData, getRandTOut(redisLongTimeCache));
- }
- if (result == null)
- {
- result = new PODLModel();
- }
- activity?.SetTag("data.source", source);
- activity?.SetTag("result.count", 1);
- activity?.Stop();
- Log.Trace($"POdlGetByOdlAsync | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
- }
- else
- {
- Log.Debug("Errore IdxODL = 0");
- }
- return result;
+ string currKey = $"{Utils.redisPOdlByOdl}:{idxODL}";
+ return await GetOrFetchAsync(
+ operationName: "POdlGetByOdlAsync",
+ cacheKey: currKey,
+ expiration: TimeSpan.FromMinutes(redisLongTimeCache),
+ fetchFunc: async () => await dbController.PODL_getByOdlAsync(idxODL) ?? new(),
+ tagList: [Utils.redisPOdlByOdl]
+ );
}
///
@@ -2411,33 +2381,24 @@ namespace MP.SPEC.Data
///
public async Task
> TksScoreAsync(string KeyFilt, int MaxResult, bool ForceDb)
{
- using var activity = ActivitySource.StartActivity("TksScoreAsync");
- string source = "DB";
- List? result = new List();
- // cerco in redis...
string currKey = $"{Utils.redisKitScore}:{KeyFilt}:{MaxResult}";
- RedisValue rawData = await redisDb.StringGetAsync(currKey);
- if (rawData.HasValue && !ForceDb)
+
+ if (ForceDb)
{
- result = JsonConvert.DeserializeObject>($"{rawData}");
- source = "REDIS";
+ // Se ForceDb รจ true, saltiamo il GetOrFetchAsync per forzare il fetch dal DB
+ // e aggiornare la cache.
+ var result = await dbController.TksScoreAsync(KeyFilt, MaxResult) ?? new List();
+ await _cache.SetAsync(currKey, result, TimeSpan.FromMinutes(redisLongTimeCache), tags: [Utils.redisKitScore]);
+ return result;
}
- else
- {
- result = await dbController.TksScoreAsync(KeyFilt, MaxResult);
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- await redisDb.StringSetAsync(currKey, rawData, TimeSpan.FromSeconds(redisLongTimeCache));
- }
- if (result == null)
- {
- result = new List();
- }
- activity?.SetTag("data.source", source);
- activity?.SetTag("result.count", result.Count);
- activity?.Stop();
- LogTrace($"TksScoreAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
- return result;
+
+ return await GetOrFetchAsync(
+ operationName: "TksScoreAsync",
+ cacheKey: currKey,
+ expiration: TimeSpan.FromMinutes(redisLongTimeCache),
+ fetchFunc: async () => await dbController.TksScoreAsync(KeyFilt, MaxResult) ?? new List(),
+ tagList: [Utils.redisKitScore]
+ );
}
///
@@ -2542,33 +2503,14 @@ namespace MP.SPEC.Data
///
public async Task> WipKitFiltAsync(string KeyFilt)
{
- using var activity = ActivitySource.StartActivity("WipKitFiltAsync");
- string source = "DB";
- List? result = new List();
- // cerco in redis...
string currKey = $"{Utils.redisKitWip}:{KeyFilt}";
- RedisValue rawData = await redisDb.StringGetAsync(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- source = "REDIS";
- }
- else
- {
- result = await dbController.WipKitFiltAsync(KeyFilt);
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- await redisDb.StringSetAsync(currKey, rawData, TimeSpan.FromSeconds(redisLongTimeCache));
- }
- if (result == null)
- {
- result = new List();
- }
- activity?.SetTag("data.source", source);
- activity?.SetTag("result.count", result.Count);
- activity?.Stop();
- LogTrace($"WipKitFiltAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
- return result;
+ return await GetOrFetchAsync(
+ operationName: "WipKitFiltAsync",
+ cacheKey: currKey,
+ expiration: TimeSpan.FromMinutes(redisLongTimeCache),
+ fetchFunc: async () => await dbController.WipKitFiltAsync(KeyFilt) ?? new List(),
+ tagList: [Utils.redisKitWip]
+ );
}
///