緩存依賴

文件依賴,文件改變,緩存清除緩存

  XmlDocument xmlDoc = new XmlDocument();
        public XmlHelper()
        {
            string xmlPath = HttpRuntime.AppDomainAppPath + "\\Config.xml";
            //xmlDoc.Load(xmlPath);
			xmlDoc=GetXmlDocument(xmlPath);
        }

		public static XmlDocument GetXmlDocument(string xmlPath)
		{
			XmlDocument doc = new XmlDocument();
			string key = "config.xml";
			Object obj = DataCache.GetCache(key);

			if (obj == null)
			{
				doc.Load(xmlPath);

				DataCache.SetCache(key, doc, new CacheDependency(xmlPath));
			}
			else
			{
				doc = (XmlDocument)obj;
			}

			return doc;

		}
相關文章
相關標籤/搜索