麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > .NET > 正文

ASP.NET緩存處理類實例

2024-07-10 13:29:09
字體:
來源:轉載
供稿:網友

這篇文章主要介紹了ASP.NET緩存處理類,實例分析了asp.net緩存的使用技巧,需要的朋友可以參考下

本文實例講述了ASP.NET緩存處理類。分享給大家供大家參考。具體如下:

ASP.NET 緩存處理類。

用法:

Just copy this code into a new class file (.cs) and add it to your ASP .NET website. One thing to keep in mind is that data stored in ASP .NET Cache can be accessible across all sessions. So when creating a cacheID for the object to be stored, it must be unique (or it could be overwritten). I usually store the unique cacheID in the session and then use that to referrence the cacheID. (e.g. CacheHandler.Write(Session["MyCacheData"], myData);)

具體代碼如下:

 

 
  1. using System; 
  2. using System.Collections.Generic; 
  3. using System.Web.Caching; 
  4. using System.Web; 
  5. /// <summary> 
  6. /// This class reads/writes to ASP .NET server cache. For the sake of  
  7. /// simplicity, the class writes objects to cache with no expirateion. 
  8. /// Use the Remove() function to programmatically remove objects stored 
  9. /// from the server cache. This class was created as an alternative to  
  10. /// storing large objects in the session. 
  11. /// </summary> 
  12. public class CacheHandler 
  13. public static bool Write(string cacheID, object data) 
  14. if (HttpContext.Current == null
  15. return false
  16. if (cacheID == null || cacheID.Equals("")) 
  17. return false
  18. HttpRuntime.Cache.Insert( 
  19. cacheID, data, null, Cache.NoAbsoluteExpiration,  
  20. Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null 
  21. ); 
  22. return true
  23. public static object Read(string cacheID) 
  24. if (HttpContext.Current == null
  25. return null
  26. return HttpRuntime.Cache.Get(cacheID); 
  27. public static void Remove(string cacheID) 
  28. if (HttpContext.Current == null ) 
  29. return
  30. if (cacheID == null || cacheID.Equals("")) 
  31. return
  32. HttpRuntime.Cache.Remove(cacheID); 

希望本文所述對大家的asp.net程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 欧美另类视频在线 | 欧美日韩在线看片 | 欧美黄色免费视频 | 精品国产一区二区三区蜜殿 | 国产精品视频久久久 | 欧美一级免费在线观看 | 欧美成年人视频在线观看 | 九九热九九热 | wankz100%videos| 成人午夜久久 | 欧美18一19sex性护士农村 | 免费观看国产精品视频 | 91久久精品一二三区 | 49vvv| 黄色7777| 久久精品79国产精品 | 国产高潮好爽受不了了夜色 | 欧美一区二区片 | 精品国产一区二区亚洲人成毛片 | 视频国产一区二区 | 欧美成人做爰高潮片免费视频 | 午夜精品福利视频 | 羞羞视频免费网站 | 黑人一区二区三区四区五区 | 欧美特级一级毛片 | 国产亚洲黑人性受xxxx精品 | 一区二区久久久久草草 | 久久69精品久久久久久国产越南 | 激情九九 | 深夜影院一级毛片 | 免费观看三级毛片 | 中文字幕在线不卡视频 | 线观看免费完整aaa 久久不雅视频 | 黄片毛片一级 | 黄色aaa视频 | 石原莉奈日韩一区二区三区 | 久久久久久久久久综合 | 一级成人在线 | 国产精品视频导航 | 久草导航 | 成人三级在线播放 |