缓存依赖

文件依赖,文件改变,缓存清除

  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;

		}

  

posted @ 2016-05-24 13:03  哈哈2222  阅读(244)  评论(0编辑  收藏  举报