zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    地球化学图解系统GCDPlot 0.33
    《Excel VBA应用开发从基础到实践》配套源代码
    边缘化的GIS——Traditional GIS No Longer Necessary
    数据库与空间数据库
    本Blog暂停更新,请访问:http://mars.3snews.net
    ArcGIS 9.2 笔记(5):Georocessing与Python
    微软更新Photosynth Technology Preview
    ArcGIS 9.2 笔记(4):数据互操作
    技术日记20130408
    Git服务器Gitosis安装设置
  • 原文地址:https://www.cnblogs.com/simhare/p/851271.html
Copyright © 2011-2022 走看看