Use the cache technology to solve the pressure on accessing the statistical database

Source: Internet
Author: User

Cachevisit CV = new cachevisit ();
Cv. sysno = sysno;
Cv. reurl = reurl;
Cv. IP = getipv4andv6 ();
Cv. moduleclass = moduleclass;

 

If (Cache ["yddvisit"] = NULL)
{
List <cachevisit> CVS = new list <cachevisit> ();
Cvs. Add (CV );
Cache. insert ("yddvisit", CVS );
}
Else
{
List <cachevisit> CVS = (list <cachevisit>) cache ["yddvisit"];
If (CVS. Count <10)
{

Cvs. Add (CV );
Cache. insert ("yddvisit", CVS );
}
Else
{
List <cachevisit> cvs2 = (list <cachevisit>) cache ["yddvisit"];

Foreach (cachevisit CVF in cvs2)
{
If (CVF. reurl = "")
EC. biz. ICBC. icbc_product_dailyclickmanager.getinstance (). Add (CVF. sysno, "", CVF. IP, CVF. moduleclass );
Else
EC. biz. ICBC. icbc_product_dailyclickmanager.getinstance (). Add (CVF. sysno, CVF. reurl, CVF. IP, CVF. moduleclass );
}

Cache. Remove ("yddvisit ");
}
}

 

 

Every time there are 10 records updated to the database, it is better to execute SQL statements at a time!

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.