ASP built-in memory cache application

Source: Internet
Author: User

The getcache function automatically creates the required cache. CopyCode The Code is as follows: function getcache (funsname, isreset, isarr, timeinfo)
'Funsname-content to be cached. Enter a function name here.
'Isreset-whether to update [value: 0 (automatically update when cache is null is determined based on time), 1 (actively update)]
'Isarr -- whether the cached content is a data [0 is a string, 1 is an array]
'Timeinfo -- cache Update time, in seconds. If the value is 0, it is updated only when 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 re_getcache = 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

Use Time:

Copy code The Code is as follows: function output3
Output3 = ""
Set newrs1_conn.exe cute ("select top 60 companyName, comid, vipdata, ishot from company where isok = 1 and vipqx> 60 and vipqx <300 and VIP = 1 and comid in (select comid from jobs where ZT <> 1) Order by newid ()")
Do while not newrs. EOF
Output3 = output3 & "..."
Newrs. movenext
Loop
Newrs. Close
Set newrs = nothing
End Function
Response. Write getcache ("output3", 3600)
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.