国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

一個asp緩存函數,支持字符串和數組

2019-11-17 04:14:30
字體:
來源:轉載
供稿:網友

主函數
 程序代碼
<%
'***********************************************
'函數名:getcache
'作  用:將需要緩存的內容,置入緩存中,并讀取出來,如果緩存中存在該內容,則直接從緩存讀取!
'作  者: 靜¢脈(hayden)
'時  間: 2007-12-21
'參  數:funsname  ----    需要緩存的內容
'       isreset ---- 是否更新[值:0(根據時間或判斷緩存為空時自動更新)、1(主動更新)]
'       isarr  ---- 所緩存的內容是否為一個數據[0為字符串,1為數組]
'       timeinfo   ---- 緩存更新時間,單位為秒,當值為0時,則只在緩存為空時,才更新
'返回值:緩存名為"funsname”的內容
'***********************************************
Function getcache(funsname,isreset,isarr,timeinfo)
    dim domain = "myhhe.cn"    '緩存域
    Dim temp_getconfig
    Dim re_getcache : re_getcache = False
    Dim temp_isarray_type : temp_isarray_type = False
    Dim Appfunsname : Appfunsname = Replace(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
%>


調用示例:
 程序代碼
<%
Function out_test1    '返回一個字符串的示例函數
    out_test1="這里是一個字符串"
End Function

Function out_test2    '返回一個數組的示例函數
    Dim temp_out_test2
    temp_out_test2="這里.是.一個.數組"
    out_test2=Split(temp_out_test2,".")
End Function

Dim i

'字符串緩存(將函數out_test1從緩存讀取并輸出)
Dim str2 : str2 = getcache("out_test1",0,0,180)    '通過getcache函數讀取緩存.刷新時間為180秒,(當out_test1緩存為空,會自動訪問函數out_test1輸出,并同時置入緩存~)
response.write str2

response.write "<BR><BR><BR>"

'數組緩存(將函數out_test2從緩存讀取并輸出)
Dim str1 : str1 = getcache("out_test2",0,1,180)  '同上(字符串緩存說明)
For i = 0 To UBound(str1)
    response.write str1(i) & "<BR>"
Next
%>


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 定边县| 苗栗县| 夏津县| 建瓯市| 庆城县| 剑阁县| 靖江市| 文登市| 英吉沙县| 石门县| 静宁县| 莱西市| 禹州市| 新乡县| 沭阳县| 石家庄市| 藁城市| 湖北省| 绥化市| 永善县| 桐城市| 江川县| 台东市| 道孚县| 西乌珠穆沁旗| 余干县| 大名县| 虹口区| 泰来县| 宁武县| 新宾| 乌苏市| 德钦县| 合山市| 普格县| 苗栗县| 紫云| 法库县| 玛纳斯县| 卓资县| 广丰县|