ASP.NET's DataTable cache class.

xiaoxiao2021-03-06  47

Using system.web; using system.data;

Namespace sc {///

// ****************************************************** / // Description: DateTable's cache class. // Property: Name: The name of the cache. Only write // attribute: VALUES: Cache value read and write // method: Checkcache (): Check if there is a cache. Return BOOL // Method: Makecacheempty (): Clealed Cache // Instance: //version: 1.0 // Data = 2004-12-13 // Written By: Happiness .NET // ********* ************************************* / /// public class cache: system.web.ui.page {private string Name; Private DataTable Strvalue; Public Cache (String SetName) {Name = setName;}

private void SetCache (string setname, DataTable newvalue) {System.Web.HttpContext.Current.Application.Lock (); System.Web.HttpContext.Current.Application [setname] = newvalue; System.Web.HttpContext.Current.Application. Unlock ();

} Public void MakeCacheEmpty () // empty the cache {System.Web.HttpContext.Current.Application.Lock (); System.Web.HttpContext.Current.Application.Remove (name); System.Web.HttpContext.Current.Application. Unlock ();

}

Public String Name // Property: Name {set {name = value;}}

Public DataTable value // Property: Cache value {return (data) system.Web.httpContext.current.Application [name];} set {if (name! = "") {strValue = value; setCache (Name, Strvalue Else {}}}

} Public bool checkcache () // Check the cache {bool boolcheck = false; if (System.Web.httpContext.current.Application [name]! = Null) {boolcheck = true;} Return BoolCheck;}

}

转载请注明原文地址:https://www.9cbs.com/read-81187.html

New Post(0)