private void Writefile(IRealTimeNotification notification, string cacheKey) { var unixMoment = notification.ReceivedUnixMillisecondsTimestamp / 1000; var collection = _cache.GetOrAdd(cacheKey, () => new ConcurrentDictionary <long, string>(), DateTimeOffset.MaxValue); if (collection.TryAdd(unixMoment, JsonConvert.SerializeObject(notification.SerializableEntity))) { var moment = DateTimeOffset.FromUnixTimeMilliseconds(unixMoment).ToEquipmentLocalTime(_zoneProvider); _logger.Verbose("Cached {UnixTime} {Time} - Cache count {Count}", unixMoment, moment, collection.Count); } else { _logger.Debug("Cached {UnixTime} already exists for {TypeName} - Cache count {Count}", unixMoment, notification.GetType().Name, collection.Count); } }
public void Add(IRealTimeNotification notification, string cacheKey) { Writefile(notification, cacheKey); }