佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > 捌度空間 緩存類

捌度空間 緩存類

熱門標(biāo)簽:銀行業(yè)務(wù) 電子圍欄 Linux服務(wù)器 服務(wù)器配置 Mysql連接數(shù)設(shè)置 科大訊飛語音識別系統(tǒng) 阿里云 團購網(wǎng)站
捌度空間 緩存類代碼
復(fù)制代碼 代碼如下:

%
class Cache
    private obj            'cache內(nèi)容
    private expireTime        '過期時間
    private expireTimeName    '過期時間application名
    private cacheName        'cache內(nèi)容application名
    private path            'url

    private sub class_initialize()
        path=request.servervariables("url")
        path=left(path,instrRev(path,"/"))
    end sub

    private sub class_terminate()
    end sub

    public property get blEmpty
        '是否為空
        if isempty(obj) then
            blEmpty=true
        else
            blEmpty=false
        end if
    end property

    public property get valid
        '是否可用(過期)
        if isempty(obj) or not isDate(expireTime) then
            valid=false
        elseif CDate(expireTime)now then
                valid=false
        else
            valid=true
        end if
    end property

    public property let name(str)
        '設(shè)置cache名
        cacheName=str  path
        obj=application(cacheName)
        expireTimeName=str  "expires"  path
        expireTime=application(expireTimeName)
    end property

    public property let expires(tm)
        '重設(shè)置過期時間
        expireTime=tm
        application.lock
        application(expireTimeName)=expireTime
        application.unlock
    end property

    public sub add(var,expire)
        '賦值
        if isempty(var) or not isDate(expire) then
            exit sub
        end if
        obj=var
        expireTime=expire
        application.lock
        application(cacheName)=obj
        application(expireTimeName)=expireTime
        application.unlock
    end sub

    public property get value
        '取值
        if isempty(obj) or not isDate(expireTime) then
            value=null
        elseif CDate(expireTime)now then
            value=null
        else
            value=obj
        end if
    end property

    public sub makeEmpty()
        '釋放application
        application.lock
        application(cacheName)=empty
        application(expireTimeName)=empty
        application.unlock
        obj=empty
        expireTime=empty
    end sub

    public function equal(var2)
        '比較
        if typename(obj)>typename(var2) then
            equal=false
        elseif typename(obj)="Object" then
            if obj is var2 then
                equal=true
            else
                equal=false
            end if
        elseif typename(obj)="Variant()" then
            if join(obj,"^")=join(var2,"^") then
                equal=true
            else
                equal=false
            end if
        else
            if obj=var2 then
                equal=true
            else
                equal=false
            end if
        end if
    end function
end class
%>

使用方法:
復(fù)制代碼 代碼如下:

    set myCache=new cache
    myCache.name="flash1"
    If myCache.valid then
        StartGet = myCache.value
    Else
        StartGet = GetHttpPage(HttpUrl)    
        myCache.add StartGet,dateadd("h",3,Now)
    End if 
    List=GetBody(StartGet,"/form>","!-- ********網(wǎng)頁中部代碼結(jié)束******** -->",False,False)

標(biāo)簽:蚌埠 萍鄉(xiāng) 廣元 大理 衢州 江蘇 棗莊 衡水

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《捌度空間 緩存類》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    博罗县| 鹤峰县| 南昌县| 洛隆县| 平凉市| 迁西县| 北碚区| 东阿县| 合水县| 岳西县| 荔浦县| 府谷县| 信丰县| 秭归县| 尼勒克县| 临沭县| 温泉县| 金门县| 宁陵县| 洪江市| 资阳市| 林州市| 琼海市| 民县| 德清县| 曲阜市| 天峨县| 遂平县| 克拉玛依市| 阿拉善盟| 楚雄市| 彭州市| 集安市| 改则县| 青川县| 前郭尔| 昌平区| 繁昌县| 海阳市| 双牌县| 昌邑市|