using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BookDemo.DataCache
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //添加缓存
                Cache.Add("BookDemo",//缓存键
                    DateTime.Now,//缓存内容
                    null,//依赖项
                    DateTime.Now.AddSeconds(30),//过期时间
                    System.Web.Caching.Cache.NoSlidingExpiration,//使用绝对过期时间
                    System.Web.Caching.CacheItemPriority.High, //使用“高”优先级
                    null//移除对象时所调用的委托
                    );
                //if (Cache["BookDemo"].GetType().ToString().ToLower().Contains("time"))
                //    Cache["BookDemo"] = "abc"+DateTime.Now.ToString();
            }
            Response.Write("当前时间：" + DateTime.Now.ToString() + "<br />");//当前时间
            Response.Write("BookDemo的缓存内容为：" + Cache["BookDemo"].ToString());//缓存内时间


        }
    }
}
