Files
Samuele Locatelli a67359d4f6 Maat, modifiche varie
- modifica key x evitare check incrociati tra cache redis diverse
- modifiche x log
- test nuovo installer debug
2024-10-30 09:22:17 +01:00

71 lines
1.9 KiB
C#

using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Maat.Data.Services
{
/// <summary>
/// Classe di partenza x costruzione servizi di accesso dati + cache
/// </summary>
public class BaseServ
{
#region Protected Properties
/// <summary>
/// Durata cache breve (1 min circa + perturbazione percentuale 0/-10%)
/// </summary>
protected TimeSpan FastCache
{
get => TimeSpan.FromSeconds(cacheTtlShort * rnd.Next(900, 995) / 1000);
}
/// <summary>
/// Durata cache lunga (+ perturbazione percentuale 0/-10%)
/// </summary>
protected TimeSpan LongCache
{
get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 995) / 1000);
}
/// <summary>
/// Durata cache MOLTO breve (10 sec circa + perturbazione percentuale 0/-10%)
/// </summary>
protected TimeSpan UltraFastCache
{
get => TimeSpan.FromSeconds(cacheTtlShort / 6 * rnd.Next(900, 995) / 1000);
}
/// <summary>
/// Durata cache MOLTO lunga (+ perturbazione percentuale 0/-10%)
/// </summary>
protected TimeSpan UltraLongCache
{
get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 995) / 1000);
}
#endregion Protected Properties
protected static IConfiguration _configuration = null!;
#region Private Fields
/// <summary>
/// Durata cache lunga IN SECONDI (std: 5 minuti)
/// </summary>
private int cacheTtlLong = 60 * 5;
/// <summary>
/// Durata cache breve IN SECONDI (std 1 minuto)
/// </summary>
private int cacheTtlShort = 60 * 1;
private Random rnd = new Random();
#endregion Private Fields
}
}