Merge tag 'RaiseRedisWriteStats_01' into develop
Update gestione scadenze hash x redis
This commit is contained in:
@@ -1088,6 +1088,33 @@ namespace IOB_UT_NEXT
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Salvataggio di una hash di valori in formato Dictionary
|
||||
/// </summary>
|
||||
/// <param name="hashKey">chiave</param>
|
||||
/// <param name="hashFields">valori</param>
|
||||
/// <param name="expireDT">scadenza hash COME DATETIME (NULL = NON SCADE)</param>
|
||||
/// <returns></returns>
|
||||
public bool redSaveHashDict(string hashKey, Dictionary<string, string> hashFields, DateTime? expireDT )
|
||||
{
|
||||
bool answ = false;
|
||||
// cerco se ci sia valore in redis...
|
||||
try
|
||||
{
|
||||
RedisKey chiave = hashKey;
|
||||
answ = redSaveHashDict(hashKey, hashFields);
|
||||
if (expireDT !=null)
|
||||
{
|
||||
cache.KeyExpire(chiave, expireDT);
|
||||
}
|
||||
//answ = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Logging.Instance.Error($"redSaveHashDict {exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Salvataggio di una hash di valori
|
||||
|
||||
@@ -4568,14 +4568,16 @@ namespace IOB_WIN_FORM.Iob
|
||||
// se ho --> processo!
|
||||
if (numOver > 0)
|
||||
{
|
||||
DateTime scadHash = DateTime.Today.AddMonths(1);
|
||||
// salvo statistiche Day
|
||||
rKey = $"{redisMan.redIobTrackKey}:DayStats:{LastDayCurr}";
|
||||
foreach (var item in TrackDayStatsCount)
|
||||
{
|
||||
// traccio con scadenza 1 mese da oggi pareto chiamate giornaliere
|
||||
redisMan.redIncrHashCount(rKey, item.Key, null, item.Value);
|
||||
redisMan.redIncrHashCount(rKey, item.Key, scadHash, item.Value);
|
||||
}
|
||||
// salvo statistiche Detail
|
||||
// salvo statistiche Detail, scadenza 15 gg
|
||||
scadHash = DateTime.Today.AddDays(15);
|
||||
foreach (var item in TrackDetStatsCount)
|
||||
{
|
||||
// separo statistiche...
|
||||
@@ -4583,14 +4585,15 @@ namespace IOB_WIN_FORM.Iob
|
||||
if (kvp.Count() > 1)
|
||||
{
|
||||
rKey = $"{redisMan.redIobTrackKey}:DetailStats:{LastDayCurr}:{kvp[0]}";
|
||||
redisMan.redIncrHashCount(rKey, kvp[1], null, item.Value);
|
||||
redisMan.redIncrHashCount(rKey, kvp[1], scadHash, item.Value);
|
||||
}
|
||||
}
|
||||
// salvodzionario valori dettaglio...
|
||||
// salvo dizionario valori dettaglio... scadenza 5 gg
|
||||
scadHash = DateTime.Today.AddDays(5);
|
||||
foreach (var item in TrackDetValsCount)
|
||||
{
|
||||
rKey = $"{redisMan.redIobTrackKey}:DataLog:{LastDayCurr}:{item.Key}";
|
||||
redisMan.redSaveHashDict(rKey, item.Value);
|
||||
redisMan.redSaveHashDict(rKey, item.Value, scadHash);
|
||||
}
|
||||
// reset dizionari
|
||||
TrackDayStatsCount.Clear();
|
||||
|
||||
Reference in New Issue
Block a user