国产探花免费观看_亚洲丰满少妇自慰呻吟_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
%>


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 淮南市| 东阳市| 新竹县| 林州市| 葫芦岛市| 堆龙德庆县| 商洛市| 青海省| 改则县| 英德市| 福海县| 教育| 正蓝旗| 彭泽县| 衢州市| 宽城| 咸丰县| 中卫市| 永兴县| 祁东县| 青浦区| 金塔县| 中牟县| 汽车| 三门县| 思南县| 奉贤区| 武清区| 尖扎县| 中方县| 湄潭县| 旺苍县| 股票| 运城市| 全椒县| 丹寨县| 武平县| 通渭县| 平昌县| 卢龙县| 卢龙县|