.NET 使用缓存
/// <summary> /// 获取客户网站发件箱信息 /// </summary> /// <returns></returns> public static ECustomerMailServer GetCustomerMailServer() { ECustomerMailServer _ECustomerMailServer = null; if (HttpContext.Current.Cache["CustomerMailServer"] == null) { int CID = 0; int.TryParse(ConfigurationManager.AppSettings["CID"], out CID); _ECustomerMailServer = new ECustomerMailServer(); _ECustomerMailServer = new CustomerMailServerBLL().GetCustomerMailServer(CID); HttpContext.Current.Cache.Add("CustomerMailServer", _ECustomerMailServer, new CacheDependency(HttpContext.Current.Server.MapPath("~/web.config")), DateTime.Now.AddMonths(1), TimeSpan.Zero, CacheItemPriority.High, null); } else { _ECustomerMailServer = (ECustomerMailServer)HttpContext.Current.Cache["CustomerMailServer"]; } return _ECustomerMailServer; }