move data stores into their own folders like the go project

This commit is contained in:
2026-08-06 16:24:04 -05:00
parent e17fbc14a0
commit 984e8da231
5 changed files with 5 additions and 4 deletions
+29
View File
@@ -0,0 +1,29 @@
using System.Collections.Concurrent;
using System.Numerics;
namespace SafelyYou.Data;
public sealed class UploadTimes
{
private readonly Lock _lock = new();
private readonly ConcurrentDictionary<DeviceId, (BigInteger TotalUploadTime, int UploadCounts)> _uploadHistories = new();
public void Add(DeviceId deviceId, BigInteger uploadTimeNanos)
{
lock (_lock)
{
if (!_uploadHistories.TryGetValue(deviceId, out var history))
{
history = (BigInteger.Zero, 0);
}
_uploadHistories[deviceId] = (history.TotalUploadTime + uploadTimeNanos, history.UploadCounts + 1);
}
}
public BigInteger AverageUploadTimeNanoseconds(DeviceId deviceId)
{
if (!_uploadHistories.TryGetValue(deviceId, out var history)) return BigInteger.Zero;
return history.TotalUploadTime / history.UploadCounts;
}
}