Review pulizia key redis
This commit is contained in:
@@ -114,6 +114,7 @@ namespace MP.RIOC.Services
|
||||
}
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Recupera il TTL residuo di una chiave Redis (-1 = nessun TTL, -2 = chiave non esiste)
|
||||
/// </summary>
|
||||
@@ -124,7 +125,8 @@ namespace MP.RIOC.Services
|
||||
return _db.KeyTimeToLive(key);
|
||||
}
|
||||
catch { return null; }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Processing dati giornalieri (da Redis a DB)
|
||||
@@ -174,18 +176,19 @@ namespace MP.RIOC.Services
|
||||
if (!TryParseKeyMetadata(sKey, out var meta) || meta.IsHourType) continue;
|
||||
|
||||
// Verifica se la chiave è "orfana"
|
||||
bool isOrphanKey = meta.Timestamp < currentDayStart;
|
||||
#if false
|
||||
bool isOrphanKey = false;
|
||||
var keyTtl = GetKeyTtl(sKey);
|
||||
if (keyTtl == null)
|
||||
{
|
||||
// Nessun TTL recuperato = chiave senza scadenza = orfana se > 30 gg
|
||||
DateTime cutoffDay = DateTime.Today.AddDays(-30);
|
||||
isOrphanKey = meta.Timestamp < cutoffDay;
|
||||
isOrphanKey = meta.Timestamp < currentDayStart;
|
||||
}
|
||||
else
|
||||
{
|
||||
isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalDays < 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Se è orfana e abbiamo il permesso, segnamola per la cancellazione
|
||||
// NOTA: non usiamo il confronto con currentDayStart perché taglierebbe fuori
|
||||
@@ -326,6 +329,8 @@ namespace MP.RIOC.Services
|
||||
if (!TryParseKeyMetadata(sKey, out var meta) || !meta.IsHourType) continue;
|
||||
|
||||
// Verifica se la chiave è "orfana"
|
||||
bool isOrphanKey = meta.Timestamp < currentHourStart;
|
||||
#if false
|
||||
bool isOrphanKey = false;
|
||||
var keyTtl = GetKeyTtl(sKey);
|
||||
if (keyTtl == null)
|
||||
@@ -337,7 +342,8 @@ namespace MP.RIOC.Services
|
||||
else
|
||||
{
|
||||
isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalDays < 15;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Se è orfana e abbiamo il permesso, segnamola per la cancellazione
|
||||
// NOTA: non usiamo il confronto con currentHourStart perché taglierebbe fuori
|
||||
|
||||
Reference in New Issue
Block a user