a67359d4f6
- modifica key x evitare check incrociati tra cache redis diverse - modifiche x log - test nuovo installer debug
71 lines
1.9 KiB
C#
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
|
|
}
|
|
}
|