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);
    //获取缓存中所有项的总数

            }
  • 相关阅读:
    C/C++多文件之间的变量定义
    PKU POJ 2186 Popular Cows 强连通分量
    重载函数
    ZOJ 2763 Prison Break
    201357 训练赛总结
    hdu 4467 Graph 构造
    201356 训练赛总结
    201353 NEERC 2012, Eastern subregional contest
    2013512 CF 183 总结
    一道动态规划
  • 原文地址:https://www.cnblogs.com/yinpeng186/p/1939182.html
Copyright © 2011-2022 走看看