• C#缓存


    代码
     protected void Page_Load(object sender, EventArgs e)
            {
                ArrayList myarray 
    = new ArrayList();
                myarray.Add(
    "1.学习园地");
                myarray.Add(
    "2.交流论坛");
                myarray.Add(
    "3.帮助");
                
    //将数组添加到缓存中——使用Add方法
                Cache.Add("Category", myarray, null, DateTime.Now.AddSeconds(60), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Normal, null);
                myarray[
    1= "2.hello";
                Cache.Insert(
    "Catory", myarray);//使用insert方法修改缓存数据
                string tmpstr = "这是一个临时数据";
                Cache[
    "tmpdata"= tmpstr;
                Response.Write(Cache.Get(
    "tmpdata").ToString());//使用get方法获得缓存数据
                if (Cache["Category"].GetType().Name == "ArrayList")//用gettype()获取类型
                    Response.Write("类型是数组");
                IDictionaryEnumerator mycache 
    = Cache.GetEnumerator();//使用GetEnumerator遍历缓存中的数据
                while (mycache.MoveNext())
                {
                    Response.Write(mycache.Value 
    + "</br>");//这里读取出来是arraylist对象,要进行类型转换
                }
                Cache.Remove(
    "tmpdata");
                Response.Write(Cache.Count);
    //获取缓存中所有项的总数

            }
  • 相关阅读:
    利用JQuery一步步打造无缝滚动新闻
    asp.net操作oracle存储过程的小问题
    C# Tostring() 格式大全 [转]
    Oracle存储过程总结【转】
    JQuery中text()、html()和val()的区别
    JQuery的JSON数据格式
    HDU 1065 I Think I Need a Houseboat
    POJ1251 Jungle Roads
    HDU3177 Crixalis's Equipment
    HDU1042 N!
  • 原文地址:https://www.cnblogs.com/yinpeng186/p/1939182.html
Copyright © 2020-2023  润新知