asp.net the DataTable cache class.

Source: Internet
Author: User
Tags bool httpcontext net return string
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;
}

}
}





Related Article

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.