Update gestione tags x eliminazione cache ottimizzata
This commit is contained in:
@@ -122,21 +122,17 @@ namespace MP.Data.Controllers
|
||||
/// <param name="TableName">Nome Table x filtro (std: EvList)</param>
|
||||
/// <param name="FieldName">Nome Field x filtro (std: Common)</param>
|
||||
/// <returns></returns>
|
||||
public List<vSelEventiBCodeModel> AnagEventiGeneral(string TableName = "EvList", string FieldName = "Common")
|
||||
public async Task<List<vSelEventiBCodeModel>> AnagEventiGeneralAsync(string TableName = "EvList", string FieldName = "Common")
|
||||
{
|
||||
List<vSelEventiBCodeModel> dbResult = new List<vSelEventiBCodeModel>();
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var pTableName = new SqlParameter("@TableName", TableName);
|
||||
var pFieldName = new SqlParameter("@FieldName", FieldName);
|
||||
dbResult = dbCtx
|
||||
.DbSetVSEB
|
||||
.FromSqlRaw("exec dbo.stp_vseb_getGenerallyAvailable @TableName, @FieldName", pTableName, pFieldName)
|
||||
.AsNoTracking()
|
||||
.AsEnumerable()
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
var pTableName = new SqlParameter("@TableName", TableName);
|
||||
var pFieldName = new SqlParameter("@FieldName", FieldName);
|
||||
var dbResult = await dbCtx
|
||||
.DbSetVSEB
|
||||
.FromSqlRaw("exec dbo.stp_vseb_getGenerallyAvailable @TableName, @FieldName", pTableName, pFieldName)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
return dbResult ?? new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -157,35 +157,25 @@ namespace MP.SPEC.Data
|
||||
/// Elenco EVENTI validi x ogni macchina secondo conf standard macchina
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<vSelEventiBCodeModel> AnagEventiGeneral()
|
||||
public async Task<List<vSelEventiBCodeModel>> AnagEventiGeneralAsync()
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("AnagEventiGeneral");
|
||||
string source = "DB";
|
||||
List<vSelEventiBCodeModel>? result = new List<vSelEventiBCodeModel>();
|
||||
// cerco in redisConn...
|
||||
string currKey = $"{Utils.redisEventList}:VSEB:GENERAL";
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<vSelEventiBCodeModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.AnagEventiGeneral();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<vSelEventiBCodeModel>();
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.SetTag("result.count", result.Count);
|
||||
activity?.Stop();
|
||||
LogTrace($"AnagEventiGeneral | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return result;
|
||||
string redisKey = $"{Utils.redisEventList}:VSEB:GENERAL";
|
||||
|
||||
return await GetOrFetchAsync(
|
||||
operationName: "AnagEventiGeneralAsync",
|
||||
cacheKey: redisKey,
|
||||
expiration: getRandTOut(redisLongTimeCache),
|
||||
fetchFunc: async () =>
|
||||
{
|
||||
RedisValue rawData = await redisDb.StringGetAsync(redisKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<List<vSelEventiBCodeModel>>($"{rawData}") ?? new List<vSelEventiBCodeModel>();
|
||||
}
|
||||
|
||||
return await dbController.AnagEventiGeneralAsync() ?? new List<vSelEventiBCodeModel>();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -212,7 +212,7 @@ namespace MP.SPEC.Pages
|
||||
private async Task ReloadData()
|
||||
{
|
||||
CurrMSE = await MDService.MseGetAll(false);
|
||||
SearchFermate = MDService.AnagEventiGeneral();
|
||||
SearchFermate = await MDService.AnagEventiGeneralAsync();
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
Reference in New Issue
Block a user