asp.net| cache using System;
Using System.Web;
Using System.Data;
Namespace SC
{
<summary>
//**************************************/
Description: Datetable the Cache class.
Property: Name: The names of the caches. Write only
Attributes: Values: Cached value reads and writes
Method: Checkcache (): Check for cache. Back to BOOL
Method: Makecacheempty (): Empty cache
Instance:
version:1.0
Data=2004-12-13
Written by: happy. Net
//**************************************/
</summary>
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 ()/Clear 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 values//Property: Cached Value
{
Get
{
Return (DataTable) system.web.httpcontext.current.application[name];
}
Set
{
if (name!= "")
{
Strvalue=value;
Setcache (Name,strvalue);
}
else{}
}
}
public bool Checkcache ()//Check Cache
{
BOOL Boolcheck=false;
if (system.web.httpcontext.current.application[name]!=null)
{
Boolcheck=true;
}
return boolcheck;
}
}
}