Files
maat/Maat.Data/Services/BaseServ.cs
T
Samuele Locatelli 0180c6faf5 - rename servizio interno
- update README
2024-04-05 09:10:35 +02: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, 999) / 1000);
}
/// <summary>
/// Durata cache lunga (+ perturbazione percentuale 0/-10%)
/// </summary>
protected TimeSpan LongCache
{
get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 999) / 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, 999) / 1000);
}
/// <summary>
/// Durata cache MOLTO lunga (+ perturbazione percentuale 0/-10%)
/// </summary>
protected TimeSpan UltraLongCache
{
get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 999) / 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
}
}