Estensione metodi di lettura QUEUE

This commit is contained in:
Samuele Locatelli
2023-04-19 08:26:17 +02:00
parent 33a43ce370
commit b031dd0bec
2 changed files with 102 additions and 16 deletions
@@ -128,8 +128,29 @@ namespace WebDoorCreator.API.Data
return numReq;
}
/// <summary> Get calculation request pending as Dictionary<string, string> --> (doorId,
/// revnumb) </summary>
/// <summary>
/// Get # of calculation request processing
/// </summary>
public async Task<long> NumRequestProcessing()
{
long numReq = 0;
string source = "REDIS";
Dictionary<string, string> dictResult = new Dictionary<string, string>();
// cerco da cache
RedisKey currKey = new RedisKey(Constants.CALC_REQ_PROC);
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
numReq = await redisDb.HashLengthAsync(currKey);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"NumRequestProcessing | {source} in: {ts.TotalMilliseconds} ms");
return numReq;
}
/// <summary>
/// Get Queue request pending
/// </summary>
/// <returns>Dictionary of DoorId, saveVersNumb</returns>
public async Task<Dictionary<string, string>> RequestPending()
{
string source = "REDIS";
@@ -153,6 +174,33 @@ namespace WebDoorCreator.API.Data
Log.Debug($"RequestPending | {source} in: {ts.TotalMilliseconds} ms");
return dictResult;
}
/// <summary>
/// Get Queue request processing
/// </summary>
/// <returns>Dictionary of DoorId, saveVersNumb</returns>
public async Task<Dictionary<string, string>> RequestProcessing()
{
string source = "REDIS";
long numReq = 0;
Dictionary<string, string> dictResult = new Dictionary<string, string>();
// cerco da cache
RedisKey currKey = new RedisKey(Constants.CALC_REQ_PROC);
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
numReq = redisDb.HashLength(currKey);
if (numReq > 0)
{
var rawData = await redisDb.HashGetAllAsync(currKey);
foreach (var item in rawData)
{
dictResult.Add($"{item.Name}", $"{item.Value}");
}
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"RequestProcessing | {source} in: {ts.TotalMilliseconds} ms");
return dictResult;
}
#endregion Public Methods