Exemple #1
0
        internal static ReadOnlyCollection <T> GetList <T>(HttpContextBase context, string method, string cacheKeyFormat)
        {
            var cookie   = new WebCookies(context);
            var cache    = new WebCache(context);
            var userId   = cookie.UserAuthCookie;
            var cacheKey = string.Format(cacheKeyFormat, userId);
            var list     = cache.Get <ReadOnlyCollection <T> >(cacheKey);

            if (list == null)
            {
                list = GetRemote <List <T> >(context, method, userId).AsReadOnly();
                cache.Add(cacheKey, list);
            }
            return(list);
        }
Exemple #2
0
        internal static T Get <T>(HttpContextBase context, string method, string cacheKeyFormat) where T : class
        {
            var cookie   = new WebCookies(context);
            var cache    = new WebCache(context);
            var userId   = cookie.UserAuthCookie;
            var cacheKey = string.Format(cacheKeyFormat, userId);
            var obj      = cache.Get <T>(cacheKey);

            if (obj == null)
            {
                obj = GetRemote <T>(context, method, userId);
                cache.Add(cacheKey, obj);
            }
            return(obj);
        }