0df7a2cd81
Aggiunta api alive x cancellazione vecchi dati redis e mongoDB
51 lines
1.6 KiB
C#
51 lines
1.6 KiB
C#
using AppData;
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.Web.Http;
|
|
|
|
namespace NKC_WF.Controllers
|
|
{
|
|
/// <summary>
|
|
/// Classe verifica stato ALIVE del servizio
|
|
/// </summary>
|
|
public class AliveController : ApiController
|
|
{
|
|
#region Public Methods
|
|
|
|
// GET: api/Alive
|
|
[HttpGet]
|
|
public string Get()
|
|
{
|
|
return "OK";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Effettua operazioni pulizia memoria dati su redis e MongoDB
|
|
/// GET: api/Alive/MaxRec
|
|
/// </summary>
|
|
/// <param name="id">Rappresenta il num di record MAX da mantenere in memoria</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public string Get(int id)
|
|
{
|
|
// check valore minimo ammesso parametro numero env da mantenere
|
|
int n2k = 1500;
|
|
id = id > n2k ? id : n2k;
|
|
Stopwatch sw = new Stopwatch();
|
|
sw.Start();
|
|
// recupero contatore attuale
|
|
var currCount = ComLib.GetCurrMCount();
|
|
// calcolo ultimo ID da tenere
|
|
var idxMin = currCount - id;
|
|
// elimino da mongo DB i record registrati...
|
|
int numDelMongo = ComLib.CleanupMongo(idxMin);
|
|
// inizio processando 1:1 da MList ed elimino hash + relativa cache
|
|
int numDelRedis = ComLib.CleanupRedis(idxMin);
|
|
|
|
sw.Stop();
|
|
return $"Effettuata pulizia memoria Redis + MongoDB | idx min: {idxMin} | Redis del: {numDelRedis} | Mongo del: {numDelMongo} | {(double)sw.ElapsedMilliseconds / 1000:N2} sec";
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |