zoukankan      html  css  js  c++  java
  • 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);
    //获取缓存中所有项的总数

            }
  • 相关阅读:
    二分
    枚举
    dp
    bfs
    bfs
    dfs
    ipython快捷键
    虚拟机串口连接嵌入式开发板
    rtmp向IR601移植过程(无功能步骤,只有移植步骤)
    静态库和动态库
  • 原文地址:https://www.cnblogs.com/yinpeng186/p/1939182.html
Copyright © 2011-2022 走看看