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 /// 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 /// 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 ); } } |