private DataTable Get(string key) { DataTable dtKey = CacheAccess.GetFromCache(key) as DataTable; if (dtKey == null) { dtKey = configSection.GetSectionList(key); CacheAccess.SaveToCache(key, dtKey, GetSectionConfigCacheDependency()); } return(dtKey); }
private string Get(string key) { string iKey = CacheAccess.GetFromCache(key) as string; if (iKey == "" || iKey == null) { iKey = configDialog.GetDialogSingle(key); CacheAccess.SaveToCache(key, iKey, GetDialogConfigCacheDependency()); } return(iKey); }
/// <summary> /// 反序列化Site配置文件 /// </summary> /// <returns></returns> public SiteConfigInfo LoadConfig() { SiteConfigInfo siteConfigInfo = (SiteConfigInfo)CacheAccess.GetFromCache("SITECONFIG"); if (siteConfigInfo == null) { siteConfigInfo = (SiteConfigInfo)SerializerXML.Load(typeof(SiteConfigInfo), path); CacheDependency cmsConfigDependency = new CacheDependency(path); CacheAccess.SaveToCache("SITECONFIG", siteConfigInfo, cmsConfigDependency); } return(siteConfigInfo); }
/// <summary> /// 反序列化CMS配置文件 /// </summary> /// <returns></returns> public CMSConfigInfo LoadConfig() { CMSConfigInfo cmsConfigInfo = (CMSConfigInfo)CacheAccess.GetFromCache("CMSCONFIG"); if (cmsConfigInfo == null) { cmsConfigInfo = (CMSConfigInfo)SerializerXML.Load(typeof(CMSConfigInfo), path); CacheDependency cmsConfigDependency = new CacheDependency(path); CacheAccess.SaveToCache("CMSCONFIG", cmsConfigInfo, cmsConfigDependency); } return(cmsConfigInfo); }
/// <summary> /// 获取配置文件信息工厂 /// </summary> /// <param name="configName">配置文件类名</param> /// <returns>数据访问类对象</returns> public static T LoadConfig <T>(string configName) where T : IConfigInfo { string path = GetPath(configName); object configObj = CacheAccess.GetFromCache(configName); if (configObj == null) { configObj = SerializerXML.Load(typeof(T), path); CacheDependency configDependency = new CacheDependency(path); CacheAccess.SaveToCache(configName, configObj, configDependency); } return((T)configObj); }
/// <summary> /// 取得数据访问层对象 /// 首先检查缓存中是否存在,如不存在则用反射加载 /// </summary> /// <param name="className">数据访问类名称</param> /// <returns>数据访问对象</returns> public static object GetDALObject(string className) { object dalObject = CacheAccess.GetFromCache(className); if (null == dalObject) { string dalName = ConfigurationManager.AppSettings["DAL"]; string fullClassName = dalName + "." + className; CacheDependency fileDependency = new CacheDependency(HttpContext.Current.Server.MapPath("Web.Config")); dalObject = Assembly.Load(dalName).CreateInstance(fullClassName); CacheAccess.SaveToCache(className, dalObject, fileDependency); } return(dalObject); }
protected void Button2_Click(object sender, EventArgs e) { long execTime = 0; System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); CacheAccess.SaveToCache("Path", "uploads\\users"); for (int i = 0; i < 100000; i++) { string path = CacheAccess.GetFromCache("Path").ToString(); } sw.Stop(); execTime = sw.ElapsedMilliseconds; JScript.ShowMessage(this, string.Format("用时{0}毫秒", execTime.ToString())); }
/// <summary> /// 获取所有机场数据列表 /// </summary> /// <returns></returns> private static DataTable GetAllAirPortData() { DataTable dt = (DataTable)CacheAccess.GetFromCache("AirPortData_Cache"); if (dt != null) { return(dt); } DataSet ds = new DataSet(); if (!File.Exists(AirPortDataPath)) { throw new Exception("机场数据文件不存在!"); } ds.ReadXml(AirPortDataPath); //写入缓存 CacheAccess.SaveToCache("AirPortData_Cache", ds.Tables[0], DateTime.Now.AddDays(1)); return(ds.Tables[0]); }
/// <summary> /// 得到模板 /// </summary> /// <param name="filePath">模板先对路径</param> /// <returns></returns> public string GetTemplate(string filePath) { object obj = CacheAccess.GetFromCache(filePath); if (obj != null) { return(obj as string); } else { try { string template = FileAccessHelper.ReadTextFile(Utils.GetPhysicalPath(string.Format("~/{0}", filePath))); CacheAccess.SaveToCache(filePath, template); return(template); } catch { return("此模板文件不存在"); } } }