update cache timeout vari
This commit is contained in:
@@ -81,7 +81,7 @@ namespace MP.Data.Services.IOC
|
||||
result = await GetCurrOdlByProdAsync(idxMacchina);
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
_redisDb.StringSet(currKey, rawData, GetRandTOut(redisLongTimeCache));
|
||||
_redisDb.StringSet(currKey, rawData, GetRandTOut(redisLongTimeCache * 2));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -96,12 +96,13 @@ namespace MP.Data.Services.IOC
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> IobInsEnabAsync(string idxMacchina)
|
||||
{
|
||||
#if false
|
||||
string cacheKey = $"IOC_IobInsEnab_{idxMacchina}";
|
||||
return await GetOrFetchAsync(cacheKey, async () =>
|
||||
{
|
||||
var key = MP.Data.Utils.RedKeyDatiMacc(idxMacchina, MpIoNS);
|
||||
var rKey = MP.Data.Utils.RedKeyDatiMacc(idxMacchina, MpIoNS);
|
||||
|
||||
string? val = await _redisDb.HashGetAsync(key, "insEnabled");
|
||||
string? val = await _redisDb.HashGetAsync(rKey, "insEnabled");
|
||||
|
||||
if (val == null)
|
||||
{
|
||||
@@ -110,7 +111,25 @@ namespace MP.Data.Services.IOC
|
||||
}
|
||||
|
||||
return val != null && (val == "1" || val.ToLower() == "true");
|
||||
}, TimeSpan.FromSeconds(5));
|
||||
}, TimeSpan.FromSeconds(5));
|
||||
#endif
|
||||
|
||||
bool answ = false;
|
||||
// ORA recupero da memoria redis...
|
||||
var rKey = MP.Data.Utils.RedKeyDatiMacc(idxMacchina, MpIoNS);
|
||||
RedisValue rawData = await _redisDb.HashGetAsync(rKey, (RedisValue)"insEnabled");
|
||||
// se è vuoto... leggo da DB e popolo!
|
||||
if (!rawData.HasValue)
|
||||
{
|
||||
await ResetDatiMacchinaAsync(idxMacchina);
|
||||
// riprovo
|
||||
rawData = await _redisDb.HashGetAsync(rKey, (RedisValue)"insEnabled");
|
||||
}
|
||||
|
||||
// provo conversione
|
||||
bool.TryParse($"{rawData}", out answ);
|
||||
return answ;
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -493,25 +512,18 @@ namespace MP.Data.Services.IOC
|
||||
{
|
||||
bool answ = false;
|
||||
// ORA recupero da memoria redis...
|
||||
try
|
||||
var rKey = MP.Data.Utils.RedKeyDatiMacc(idxMacchina, MpIoNS);
|
||||
RedisValue rawData = await _redisDb.HashGetAsync(rKey, (RedisValue)"sLogEnabled");
|
||||
// se è vuoto... leggo da DB e popolo!
|
||||
if (!rawData.HasValue)
|
||||
{
|
||||
var currHash = MP.Data.Utils.RedKeyDatiMacc(idxMacchina, MpIoNS);
|
||||
RedisValue rawData = await _redisDb.HashGetAsync(currHash, (RedisValue)"sLogEnabled");
|
||||
// se è vuoto... leggo da DB e popolo!
|
||||
if (!rawData.HasValue)
|
||||
{
|
||||
await ResetDatiMacchinaAsync(idxMacchina);
|
||||
// riprovo
|
||||
rawData = await _redisDb.HashGetAsync(currHash, (RedisValue)"sLogEnabled");
|
||||
}
|
||||
await ResetDatiMacchinaAsync(idxMacchina);
|
||||
// riprovo
|
||||
rawData = await _redisDb.HashGetAsync(rKey, (RedisValue)"sLogEnabled");
|
||||
}
|
||||
|
||||
// provo conversione
|
||||
bool.TryParse($"{rawData}", out answ);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Errore IobSLogEnabAsync | idxMacchina {idxMacchina}:{Environment.NewLine}{exc}");
|
||||
}
|
||||
// provo conversione
|
||||
bool.TryParse($"{rawData}", out answ);
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -832,7 +844,7 @@ namespace MP.Data.Services.IOC
|
||||
result.Add("palletChange", $"{dbResult.PalletChange}");
|
||||
// durata cache in secondi dal valOut insEnabled...
|
||||
//double numSecCache = ((result["insEnabled"].ToLower() == "true") ? redisShortTimeCache : redisLongTimeCache);
|
||||
numSecCache = dbResult.InsEnabled ? redisShortTimeCache : redisLongTimeCache;
|
||||
numSecCache = dbResult.InsEnabled ? redisShortTimeCache * 2 : redisLongTimeCache;
|
||||
}
|
||||
|
||||
// dati master/slave
|
||||
@@ -853,7 +865,7 @@ namespace MP.Data.Services.IOC
|
||||
// 3. Inseriamo i nuovi valori
|
||||
_ = transaction.HashSetAsync(redKey, entries);
|
||||
// 4. Impostiamo l'expiration in un unico colpo
|
||||
_ = transaction.KeyExpireAsync(redKey, TimeSpan.FromSeconds(numSecCache));
|
||||
_ = transaction.KeyExpireAsync(redKey, GetRandTOut(numSecCache));
|
||||
// Eseguiamo tutto in un unico viaggio verso Redis
|
||||
bool success = await transaction.ExecuteAsync();
|
||||
|
||||
|
||||
@@ -479,7 +479,6 @@ namespace MP.IOC.Controllers
|
||||
try
|
||||
{
|
||||
var odl = await IOCService.GetCurrOdlAsync(id);
|
||||
//var odl = await DService.GetCurrOdlAsync(id);
|
||||
return Ok($"{odl}");
|
||||
}
|
||||
catch (Exception exc)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>8.16.2606.915</Version>
|
||||
<Version>8.16.2606.919</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MP-IOC </i>
|
||||
<h4>Versione: 8.16.2606.915</h4>
|
||||
<h4>Versione: 8.16.2606.919</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.915
|
||||
8.16.2606.919
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.915</version>
|
||||
<version>8.16.2606.919</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user