Application Techniques of memory cache application_ with ASP

Source: Internet
Author: User
function GetCache, the desired cache is automatically created.
Copy Code code as follows:

Function GetCache (Funsname,isreset,isarr,timeinfo)
' funsname-need to cache the content, here to enter a function name
' isreset– Update [value: 0 (Automatic update based on time or judgment cache is empty), 1 (active update)]
' isarr--The cached content is a data [0 is a string, 1 is an array]
' timeinfo--cache update time, in seconds, when the value is 0 o'clock, update only if the cache is empty
Dim domain = "cnzhaopin.com.cn"
Dim Temp_getconfig
Dim Re_getcache:re_getcache = False
Dim Temp_isarray_type:temp_isarray_type = False
Dim appfunsname:appfunsname = replace (replace (Funsname, (","), ")", "" ",", ",". ")
If Isarr = 1 Then temp_isarray_type = True
If isreset = 1 Then re_getcache = True
If Isreset = 2 Then
Execute ("temp_getconfig=" &funsname)
GetCache = Temp_getconfig
Exit Function
End If
IF Application (domain& "_" &Appfunsname& "_time") = "" and timeinfo<>0 Then Re_getcache = True
If not Re_getcache Then
If Temp_isarray_type Then
If not IsArray (Application (domain& "_" &appfunsname)) Then Re_getcache = True
Else
IF Application (domain& "_" &appfunsname) = "" Then Re_getcache = True
End If
End If
If not Re_getcache and timeinfo<>0 Then
If Int (DateDiff ("s", Application (domain& "_" &Appfunsname& "_time"), Now ()) >timeinfo Then = True
End If
If Re_getcache Then
Execute ("temp_getconfig=" &funsname)
Application.Lock
Application (domain& "_" &appfunsname) = Temp_getconfig
Application (domain& "_" &Appfunsname& "_time") = Now ()
Application.UnLock
Else
Temp_getconfig=application (domain& "_" &appfunsname)
End If
GetCache = Temp_getconfig
End Function


When used:

Copy Code code as follows:

Function OUTPUT3
Output3= ""
Set Newrs=conn.execute ("select" Companyname,comid,vipdata,ishot from the company where Isok=1 and Vipqx>60 and vipqx& Lt;300 and Vip=1 and Comid in (select Comid from jobs where zt<>1) Order by NEWID ())
Do as not newrs.eof
Output3=output3 & ".... ..."
Newrs.movenext
Loop
Newrs.close
Set newrs=nothing
End Function
Response.Write GetCache ("output3″,0,0,3600")

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.