• about Cache


     protected void Page_Load(object sender, EventArgs e)
        
    {
            
    decimal amzn = (decimal)Cache["amzn"];
            
    //Object objAmzn = (object)amzn;
            Response.Write(amzn);
        }

        
    protected void Page_Init(object sender, EventArgs e)
        
    {
            
    //Cache.Insert("amzn", 10.00m);
            Cache["amzn"= 30.00m;
        }

    Global.asax
    <%@ Application Language="C#"  %>
    <%@ Import Namespace="System.Data" %>

    <script runat="server">
        
    static Cache _cache;
        
    static string _path;
        
    void Application_Start(object sender, EventArgs e) 
        
    {
            
    // Code that runs on application startup
            _cache = Context.Cache;
            _path 
    = Server.MapPath("Stocks.xml");
            DataSet ds 
    = new DataSet();
            ds.ReadXml(_path);
            _cache.Insert(
    "Stocks", ds, new CacheDependency(_path), Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.Default, new CacheItemRemovedCallback(RefreshDataSet));
            
        }

        
    static void RefreshDataSet(string key, Object item, CacheItemRemovedReason reason)
        
    {
            DataSet ds 
    = new DataSet();
            ds.ReadXml(_path);
            _cache.Insert(
    "Stocks", ds, new CacheDependency(_path), Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.Default, new CacheItemRemovedCallback(RefreshDataSet));
        }
     
     
        
        
    void Application_End(object sender, EventArgs e) 
        
    {
            
    //  Code that runs on application shutdown

        }

            
        
    void Application_Error(object sender, EventArgs e) 
        

            
    // Code that runs when an unhandled error occurs

        }


        
    void Session_Start(object sender, EventArgs e) 
        
    {
            
    // Code that runs when a new session is started

        }


        
    void Session_End(object sender, EventArgs e) 
        
    {
            
    // Code that runs when a session ends. 
            
    // Note: The Session_End event is raised only when the sessionstate mode
            
    // is set to InProc in the Web.config file. If session mode is set to StateServer 
            
    // or SQLServer, the event is not raised.

        }

           
    </script>
  • 相关阅读:
    MFC程序执行过程剖析
    不同位数操作系统的 数据长度
    测试:safenet提供的CheckKey函数 内存泄漏。具体来说是句柄.
    关于更改项目名称
    内存泄漏相关的
    美化MFC 之调整静态文本的颜色 字体。 用于添加公司标题 联系方式 口号等数据
    DAVINCI DM365-DM368开发攻略——开发环境搭建(DVSDK4.02)
    Removing Unnecessary HTTP Headers in IIS and ASP.NET 在ASP.Net和IIS中删除不必要的HTTP响应头
    Implementing Singleton in C#
    WEBAPI VS WCF微软随.NET 4.5发布新REST API框架
  • 原文地址:https://www.cnblogs.com/simhare/p/851271.html
Copyright © 2020-2023  润新知