国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

ASP.NET緩存處理類,實例

2019-11-02 15:44:52
字體:
來源:轉載
供稿:網友

 本文實例講述了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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 3
豬八戒影院[www.aikan.tv/special/bajieyingyuan/]
6 37 38 39 40 using System; using System.Collections.Generic; using System.Web.Caching; using System.Web; /// <summary> /// This class reads/writes to ASP .NET server cache. For the sake of /// simplicity, the class writes objects to cache with no expirateion. /// Use the Remove() function to programmatically remove objects stored /// from the server cache. This class was created as an alternative to /// storing large objects in the session. /// </summary> public class CacheHandler { public static bool Write(string cacheID, object data) { if (HttpContext.Current == null) return false; if (cacheID == null || cacheID.Equals("")) return false; HttpRuntime.Cache.Insert( cacheID, data, null, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null ); return true; } public static object Read(string cacheID) { if (HttpContext.Current == null) return null; return HttpRuntime.Cache.Get(cacheID); } public static void Remove(string cacheID) { if (HttpContext.Current == null ) return; if (cacheID == null || cacheID.Equals("")) return; HttpRuntime.Cache.Remove(cacheID); } }

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 会理县| 犍为县| 上虞市| 澄迈县| 鄂托克前旗| 思茅市| 宝鸡市| 五峰| 黑河市| 临桂县| 利川市| 虞城县| 泊头市| 临汾市| 黄浦区| 略阳县| 丹江口市| 承德市| 铜梁县| 永善县| 乐陵市| 临沧市| 南江县| 曲松县| 托克托县| 洪江市| 钦州市| 称多县| 镇远县| 昌宁县| 上杭县| 于都县| 临颍县| 光山县| 舒兰市| 琼结县| 泸州市| 绥阳县| 谢通门县| 南投市| 高邑县|