public CacheContainerItem(ICacheContainerEnabled <TId> content) { Content = content; Expires = content.Cache_ExpireInMiliseconds == -1 ? -1 : DateTime.Now.AddMilliseconds(content.Cache_ExpireInMiliseconds).Ticks; }
public static void Cache(ICacheContainerEnabled <TId> obj) { lock (_Cache) { var type = obj.GetType(); if (!_Cache.ContainsKey(type)) { _Cache.Add(type, new Dictionary <TId, CacheContainerItem>()); } if (!_Cache[type].ContainsKey(obj.Cache_Identity)) { _Cache[type].Add(obj.Cache_Identity, new CacheContainerItem(obj)); } else { _Cache[type][obj.Cache_Identity] = new CacheContainerItem(obj); } } }
public static void CacheThis <TId>(this ICacheContainerEnabled <TId> c) { CacheContainer <TId> .Cache(c); }