Example #1
0
        /// <summary>
        /// Clean cache of anything that hasn't been accessed in 2 minutes, but keep anything that a client session has subscribed to
        /// </summary>
        public void Clean(ClientPlex clients, int secondsOld = 120)
        {
            DateTime cutoff     = DateTime.UtcNow.AddSeconds(0 - secondsOld);
            var      sacredKeys = clients.GetSubscriptions();

            foreach (var key in Cache.Keys)
            {
                if (sacredKeys.Contains(key))
                {
                    continue;
                }
                if (!Cache.TryGetValue(key, out Item item))
                {
                    continue;
                }
                if (item.LastAccessedUtc < cutoff)
                {
                    Cache.TryRemove(key, out _);
                }
            }
        }
Example #2
0
 public Diagnostics(ClientPlex clientplex, DatonCache datonCache)
 {
     ClientPlex = clientplex;
     DatonCache = datonCache;
 }