Exemple #1
0
        /// <summary>
        /// 服务器简单调用数据缓存配置获取
        /// </summary>
        /// <param name="poolname">池名称</param>
        /// <param name="key">节点属性值</param>
        /// <returns>返回节点对象</returns>
        public static CacheModel GetCommonCacheModel(string poolname, string key)
        {
            XmlDocument BaseXmldoc = new XmlDocument();
            string      filestr    = string.Empty;

            filestr = path + "App_Data\\CommonDataCache.xml";
            BaseXmldoc.LoadXml(File.ReadAllText(filestr));
            //节点对象
            XmlNode xmlnode = null;

            xmlnode = BaseXmldoc.SelectSingleNode("CONFIG/CACHES[@POOLNAME='" + poolname + "']/CACHE[@KEY=\"" + key + "\"]");
            if (xmlnode != null)
            {
                CacheModel pm = new CacheModel();
                pm.Key       = key;
                pm.Cachetype = int.Parse(xmlnode.Attributes["CACHETYPE"].Value);
                if (pm.Cachetype == 4)
                {
                    pm.ExpiredTime = DateTime.Parse(xmlnode.Attributes["CACHETIME"].Value);
                }
                else
                {
                    pm.CacheTime = int.Parse(xmlnode.Attributes["CACHETIME"].Value);
                }
                return(pm);
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
 /// <summary>
 /// 设置缓存数据
 /// </summary>
 /// <param name="poolName">缓存池名</param>
 /// <param name="PerKey">缓存key</param>
 /// <param name="Data">数据</param>
 /// <param name="CM">配置对象</param>
 public static void SetCache(string poolName, string PerKey, string Data, CacheModel CM)
 {
     if (CM != null)
     {
         if (CM.Cachetype != 4)
         {
             CacheMethod.SetMemValues(poolName, PerKey, Data, CM.CacheTime, CM.Cachetype);
         }
         else
         {
             CacheMethod.SetMemValuesExpiredTime(poolName, PerKey, Data, CM.ExpiredTime);
         }
     }
     else
     {
         CacheMethod.setMemcachedValue(poolName, PerKey, Data);
     }
 }
Exemple #3
0
        /// <summary>
        ///  给定一个节点的属性值
        /// </summary>
        /// <param name="version">版本</param>
        /// <param name="poolname">池名称</param>
        /// <param name="key">节点属性值</param>
        /// <returns>返回节点对象</returns>
        public static CacheModel GetCacheModel(string version, string poolname, string key)
        {
            XmlDocument BaseXmldoc = new XmlDocument();
            XmlDocument xmldoc     = new XmlDocument();
            string      filestr    = string.Empty;

            filestr = path + "App_Data\\" + version + "\\CacheConfig.xml";
            BaseXmldoc.LoadXml(File.ReadAllText(filestr));
            //节点对象
            XmlNode xmlnode = null;

            xmlnode = BaseXmldoc.SelectSingleNode("CONFIG/CACHES[@POOLNAME='" + poolname + "']/CACHE[@KEY=\"" + key + "\"]");

            //扩展配置文件列表
            List <string> ExtendXmlList = new List <string>();

            if (xmlnode == null)
            {
                XmlNodeList ExtendNodeList = BaseXmldoc.SelectNodes("CONFIG/EXTENDS/INCLUDE");
                if (ExtendNodeList != null && ExtendNodeList.Count > 0)
                {
                    foreach (XmlNode node in ExtendNodeList)
                    {
                        if (node.Attributes["SRC"] != null)
                        {
                            string ExtendFilePath = node.Attributes["SRC"].Value;
                            ExtendXmlList.Add(ExtendFilePath);
                        }
                    }
                    foreach (string filePath in ExtendXmlList)
                    {
                        try
                        {
                            string ExtendXmlContent = File.ReadAllText(path + "App_Data\\" + version + "\\" + filePath);
                            xmldoc.LoadXml(ExtendXmlContent);
                            xmlnode = xmldoc.SelectSingleNode("CONFIG/CACHES[@POOLNAME='" + poolname + "']/CACHE[@KEY=\"" + key + "\"]");
                        }
                        catch { }
                        if (xmlnode != null)
                        {
                            break;
                        }
                    }
                }
            }

            if (xmlnode != null)
            {
                CacheModel pm = new CacheModel();
                pm.Key       = key;
                pm.Cachetype = int.Parse(xmlnode.Attributes["CACHETYPE"].Value);
                if (pm.Cachetype == 4)
                {
                    pm.ExpiredTime = DateTime.Parse(xmlnode.Attributes["CACHETIME"].Value);
                }
                else
                {
                    pm.CacheTime = int.Parse(xmlnode.Attributes["CACHETIME"].Value);
                }
                return(pm);
            }
            else
            {
                return(null);
            }
        }