using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace EnVisage.Code.Cache { public abstract class Cache { protected virtual string CACHE_KEY {get; private set;} public IEnumerable Value { get { if (!CacheManager.Instance.IsInCache(CACHE_KEY)) SetValuesToCache(); return (IEnumerable)CacheManager.Instance.GetCacheData(CACHE_KEY); } } public Cache() { if (!CacheManager.Instance.IsInCache(CACHE_KEY)) SetValuesToCache(); } public void Invalidate() { if (CacheManager.Instance.IsInCache(CACHE_KEY)) CacheManager.Instance.RemoveFromCache(CACHE_KEY); } protected virtual void SetValuesToCache() { using (EnVisageEntities context = new EnVisageEntities()) { var value = context.ProjectAccesses.AsNoTracking().ToList(); CacheManager.Instance.AddToCache(CACHE_KEY, value); } } } }