zoukankan      html  css  js  c++  java
  • Asp.Net缓存实例

    using System.Web; 
    
    public string GetLeaderInfo(string symbol)
    {
        //获取高管信息的路径         
        XElement ele = XElement.Load("path.xml");
        string path = ele.Element("leader").Value;
    
        //首次读取缓存
        string jsoncache = HttpRuntime.Cache.Get(symbol) as string;
        if (jsoncache == null || jsoncache.Equals(""))
        {
            //读取数据
            XmlDocument doc = new XmlDocument();
            doc.Load(path);
    
            string strSearch = "root/高管信息[@代码='" + symbol + "']";
    
            XmlNode searchNode = doc.SelectSingleNode(strSearch);
            XmlElement element = (XmlElement)searchNode;
            xmltoJson json = new xmltoJson();
            jsoncache = json.XmlToJSON(element);
            //加缓存
            HttpRuntime.Cache.Insert(symbol, jsoncache, null, DateTime.UtcNow.AddMinutes(2), System.Web.Caching.Cache.NoSlidingExpiration);
        }
        return jsoncache;
    }
  • 相关阅读:
    Swift8-枚举Enumerations
    Swift7-闭包
    Swift6-函数
    Swift5-控制流
    Swift4-集合类型
    什么是node.js
    nodejs的安装
    环境变量的认识,,,
    shell是什么,各种shell的初步认识,适用于初学者
    exports和module.exports的区别
  • 原文地址:https://www.cnblogs.com/chaoa/p/2386105.html
Copyright © 2011-2022 走看看