. NET Cache Learning Notes

Source: Internet
Author: User

        public void ProcessRequest (HttpContext context) {//context.            Response.ContentType = "Text/plain"; Context.            Response.Write ("Hello World"); if (context. Request["action"] = NULL) {switch (context. Request["Action"].                    ToString ()) {case ' Add ': Add (); break; Case "SelectCount": SelectCount ();                    Break Case "File": File ();                    Break                Default:break;            }}} private void file () {FileInfo fi = new FileInfo ("Fuct.txt"); StreamWriter SW = new StreamWriter (FI.            FullName); Sw. WriteLine (New Random ().            Next (100)); Sw.            Flush (); Sw. WriteLine (New Random ().            Next (100)); Sw.            Flush (); Sw.            Close (); Sw.            Dispose (); StreamReader sr = new StreamReader (FI.            FullName); String word = Sr.            ReadLine (); Sr. ClosE (); Sr.            Dispose ();            String json = "{\" word\ ": \" "+ Word +" \ "}";        HttpContext.Current.Response.Write (JSON);            } private void Add () {TimeSpan ts = new TimeSpan (11, 0, 0); String value = httpcontext.current.request["value"].            ToString (); string key = httpcontext.current.request["Key"].            ToString ();            System.Web.Caching.Cache Objcache = Httpruntime.cache;            FileInfo fi = new FileInfo ("Fuct.txt"); System.Web.Caching.CacheDependency file = new System.Web.Caching.CacheDependency (FI.            FullName);            Objcache.insert (key, value, file, DateTime.MaxValue, TS, System.Web.Caching.CacheItemPriority.NotRemovable, NULL);            System.Web.Caching.Cache AA = HttpContext.Current.Cache; HttpContext.Current.Response.Write (AA.        Count);            } private void SelectCount () {System.Web.Caching.Cache AA = HttpContext.Current.Cache; Httpcontext.curreNt. Response.Write (AA.        Count);            } public bool IsReusable {get {return false;         }        }

  

The last few interviews have been asked to cache this thing, so take the time to simply learn the next cache to store some

And then tested the CacheDependency in the cache, which is the cache dependency. Once a dependency changes the cache, it can be used to store some configuration information in general configuration to XML and then cache this XML once the configuration modifies the cache and needs to be read again

Test the next with a txt to use as a dependency manually in the folder to modify the seemingly unaffected but use the program to modify the immediate effect of the cache was cleared

. NET Cache Learning Notes

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.