using System.Collections.Concurrent;
public static void Main()
var cache = new ConcurrentDictionary<DateTime, string>();
var old = DateTime.UtcNow.AddHours(-3);
cache.TryAdd((DateTime.Now.AddHours(-2)), "x");
cache.TryAdd((DateTime.Now.AddHours(-4)), "y");
cache.TryAdd((DateTime.Now.AddHours(-6)), "z");
Console.WriteLine("Original values:");
foreach(var kvp in cache)
Console.WriteLine(kvp.Value);
foreach (var kvp in cache)
cache.TryRemove(kvp.Key, out v);
Console.WriteLine(string.Format("Deleted value: {0}", v));
Console.WriteLine("Remaining values:");
foreach(var kvp in cache)
Console.WriteLine(kvp.Value);