public static string GetTemplateHtml(TemplateInfo templateInfo) { var directoryPath = GetTemplatesDirectoryPath(); var htmlPath = ApplicationUtils.PathCombine(directoryPath, templateInfo.Name, templateInfo.Main); var html = CacheUtils.Get <string>(htmlPath); if (html != null) { return(html); } html = ApplicationUtils.ReadText(htmlPath); CacheUtils.InsertHours(htmlPath, html, 1); return(html); }
public static Dictionary <string, int> GetDataCountsCache(int siteId) { var cacheKey = GetCacheKey(siteId); var retval = CacheUtils.Get <Dictionary <string, int> >(cacheKey); if (retval != null) { return(retval); } lock (LockObject) { retval = CacheUtils.Get <Dictionary <string, int> >(cacheKey); if (retval == null) { retval = Main.DataRepository.GetDataCounts(siteId); CacheUtils.InsertHours(cacheKey, retval, 1); } } return(retval); }
public static List <CategoryInfo> GetCategoryInfoListByCache(int siteId) { var cacheKey = GetCacheKey(siteId); var departmentInfoList = CacheUtils.Get <List <CategoryInfo> >(cacheKey); if (departmentInfoList != null) { return(departmentInfoList); } lock (LockObject) { departmentInfoList = CacheUtils.Get <List <CategoryInfo> >(cacheKey); if (departmentInfoList == null) { departmentInfoList = Main.CategoryRepository.GetCategoryInfoList(siteId); CacheUtils.InsertHours(cacheKey, departmentInfoList, 12); } } return(departmentInfoList); }