using System; using System.Collections.Generic; using System.Linq; using AsbCloudApp.Services; namespace AsbCloudInfrastructure.Services { public class TelemetryTracker : ITelemetryTracker { private IDictionary requests = new Dictionary(); private readonly TimeSpan timeout = TimeSpan.FromMinutes(6); private void DeleteOldRequestDates() { requests = requests.Where(dValue => (DateTime.Now - dValue.Value) < timeout).ToDictionary(dValue => dValue.Key, dValue => dValue.Value); } public void SaveRequestDate(string uid) { requests[uid] = DateTime.Now; DeleteOldRequestDates(); } public IEnumerable GetRequestUids() { DeleteOldRequestDates(); return requests.Keys; } } }