System.Web.Caching

Source: Internet
Author: User

System.Web.Caching Simple Package class:

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Web.Caching;4 usingsystem.web;5 usingSystem.Collections;6 7 namespaceAPP. HttpCache8 {9      Public classCachehelperTen     { One         Private StaticCache cacheobj =Httpruntime.cache; A  -         /// <summary> -         ///Simple Key,vlaue Write the         /// </summary> -         /// <param name= "key" ></param> -         /// <param name= "value" ></param> -          Public Static voidInsert (stringKeyObjectvalue) +         { - Cacheobj.insert (key, value); +         } A  at         /// <summary> -         ///set an absolute expiration time -         /// </summary> -         /// <param name= "key" ></param> -         /// <param name= "value" ></param> -         /// <param name= "absoluteexpiration" ></param> in         /// <param name= "slidingexpiration" ></param> -          Public Static voidInsert (stringKeyObjectvalue, DateTime absoluteexpiration) to         { +Cacheobj.insert (key, value,NULL, absoluteexpiration, cache.noslidingexpiration); -         } the  *         /// <summary> $         ///Set Smooth expirationPanax Notoginseng         /// </summary> -         /// <param name= "key" ></param> the         /// <param name= "value" ></param> +         /// <param name= "slidingexpiration" ></param> A          Public Static voidInsert (stringKeyObjectvalue, TimeSpan slidingexpiration) the         { +Cacheobj.insert (key, value,NULL, Cache.noabsoluteexpiration, slidingexpiration); -         } $  $         /// <summary> -         ///Get Vlaue -         /// </summary> the         /// <param name= "key" ></param> -         /// <returns></returns>Wuyi          Public Static ObjectGet (stringkey) the         { -             returnCacheobj.get (key); Wu         } -  About         /// <summary> $         ///Get Vlaue -         /// </summary> -         /// <param name= "key" ></param> -         /// <returns></returns> A          Public StaticT get<t> (stringkey) +         { the             varv =Cacheobj.get (key); -             returnv = =NULL?default(t): (t) convert.changetype (V,typeof(T)); $         } the  the         /// <summary> the         ///Remove Key the         /// </summary> -         /// <param name= "key" ></param> in         /// <returns></returns> the          Public Static voidDelete (stringkey) the         { About Cacheobj.remove (key); the         } the  the         /// <summary> +         ///Remove Key -         /// </summary> the         /// <param name= "key" ></param>Bayi         /// <returns></returns> the          Public Static ObjectRemove (stringkey) the         { -             returnCacheobj.remove (key); -         } the  the         /// <summary> the         ///Remove Key the         /// </summary> -         /// <param name= "key" ></param> the         /// <returns></returns> the          Public StaticT remove<t> (stringkey) the         {94             varv =Cacheobj.remove (key); the             returnv = =NULL?default(t): (t) convert.changetype (V,typeof(T)); the         } the 98         /// <summary> About         ///number of cache keys -         /// </summary>101          Public Static intKeycount102         {103             Get104             { the                 returnCacheobj.count;106             }107         }108 109         /// <summary> the         ///all key111         /// </summary> the          Public StaticArrayList Keyall ()113         { the             vararr =NewArrayList (); the             varitem =cacheobj.getenumerator (); the              while(item. MoveNext ())117             {118 arr. ADD (item. Key);119             } -             returnarr;121         }122 123         /// <summary>124         ///Clear All caches the         /// </summary>126          Public Static voidDeleteAll ()127         { -             varitem =cacheobj.getenumerator ();129              while(item. MoveNext ()) the             {131 Cacheobj.remove (item. Key.tostring ()); the             }133         }134     }135}
View Code

System.Web.Caching

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.