about Cache

None.gif   protected   void  Page_Load( object  sender, EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif {
InBlock.gif        
decimal amzn = (decimal)Cache["amzn"];
InBlock.gif        
//Object objAmzn = (object)amzn;
InBlock.gif
        Response.Write(amzn);
ExpandedBlockEnd.gif    }

None.gif    
protected   void  Page_Init( object  sender, EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif {
InBlock.gif        
//Cache.Insert("amzn", 10.00m);
InBlock.gif
        Cache["amzn"= 30.00m;
ExpandedBlockEnd.gif    }

Global.asax
None.gif <% @ Application Language = " C# "    %>
None.gif
<% @ Import Namespace = " System.Data "   %>
None.gif
None.gif
< script runat = " server " >
None.gif    
static  Cache _cache;
None.gif    
static   string  _path;
None.gif    
void  Application_Start( object  sender, EventArgs e) 
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif {
InBlock.gif        
// Code that runs on application startup
InBlock.gif
        _cache = Context.Cache;
InBlock.gif        _path 
= Server.MapPath("Stocks.xml");
InBlock.gif        DataSet ds 
= new DataSet();
InBlock.gif        ds.ReadXml(_path);
InBlock.gif        _cache.Insert(
"Stocks", ds, new CacheDependency(_path), Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.Default, new CacheItemRemovedCallback(RefreshDataSet));
InBlock.gif        
ExpandedBlockEnd.gif    }

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

ExpandedBlockEnd.gif    }

None.gif        
None.gif    
void  Application_Error( object  sender, EventArgs e) 
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif
InBlock.gif        
// Code that runs when an unhandled error occurs
InBlock.gif

ExpandedBlockEnd.gif    }

None.gif
None.gif    
void  Session_Start( object  sender, EventArgs e) 
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif {
InBlock.gif        
// Code that runs when a new session is started
InBlock.gif

ExpandedBlockEnd.gif    }

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

ExpandedBlockEnd.gif    }

None.gif       
None.gif
</ script >
None.gif

转载于:https://www.cnblogs.com/simhare/archive/2007/08/10/851271.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值