예제 #1
0
        private static T Obj <T>(string cacheKey, double expirationMinute = 5, Dlg_getdata g = null) where T : class, new()
        {
            T tmpData = MemoryCacheService.Default.GetCache <T>(cacheKey);

            if (tmpData == null)
            {
                lock (MemoryCacheService.Default)
                {
                    tmpData = MemoryCacheService.Default.GetCache <T>(cacheKey);
                    if (tmpData == null && g != null)
                    {
                        tmpData = (T)g.Invoke();
                        if (tmpData != null)
                        {
                            MemoryCacheService.Default.SetCache(cacheKey, tmpData, expirationMinute);
                        }
                    }
                }
            }
            return(tmpData);
        }
예제 #2
0
 private static List <T> List <T>(string cacheKey, double expirationMinute = 5, Dlg_getdata g = null) where T : class, new()
 {
     return(Obj <List <T> >(cacheKey, expirationMinute, g));
 }