<% '------------------------------------------------------------------------------------- '轉寄時請保留此聲明資訊,這段聲明不並會影響你的速度! '************************** 【先鋒緩衝類】Ver2004 ******************************** '作者:孫立宇、apollosun、ezhonghua '官方網站:http://www.lkstar.com 支援人員論壇:http://bbs.lkstar.com '電子郵件:kickball@netease.com 線上QQ:94294089 '著作權聲明:著作權沒有,盜版不究,源碼公開,各種用途均可免費使用,歡迎你到技術論壇來尋求支援。 '目前的ASP網站有越來越龐大的趨勢,資源和速度成了瓶頸 '——利用伺服器端緩衝技術可以很好解決這方面的矛盾,大大加速ASP運行和改善效率。 '本人潛心研究了各種演算法,應該說,這個類是當前最快最純淨的緩衝類。 '詳細使用說明或範例請見下載附件或到本人官方網站下載! '-------------------------------------------------------------------------------------- class clsCache '---------------------------- private cache '緩衝內容 private cacheName '緩衝Application名稱 private expireTime '緩衝到期時間 private expireTimeName '緩衝到期時間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 Version Version="先鋒緩衝類 Version 2004" End Property public property get valid '讀取緩衝是否有效/屬性 if isempty(cache) or (not isdate(expireTime)) then vaild=false else valid=true end if end property public property get value '讀取當前緩衝內容/屬性 if isempty(cache) or (not isDate(expireTime)) then value=null elseif CDate(expireTime)<now then value=null else value=cache end if end property public property let name(str) '設定緩衝名稱/屬性 cacheName=str&path cache=application(cacheName) expireTimeName=str&"expire"&path expireTime=application(expireTimeName) end property public property let expire(tm) '設定緩衝到期時間/屬性 expireTime=tm application.Lock() application(expireTimeName)=expireTime application.UnLock() end property public sub add(varCache,varExpireTime) '對緩衝賦值/方法 if isempty(varCache) or not isDate(varExpireTime) then exit sub end if cache=varCache expireTime=varExpireTime application.lock application(cacheName)=cache application(expireTimeName)=expireTime application.unlock end sub public sub clean() '釋放緩衝/方法 application.lock application(cacheName)=empty application(expireTimeName)=empty application.unlock cache=empty expireTime=empty end sub public function verify(varcache2) '比較緩衝值是否相同/方法——返回是或否 if typename(cache)<>typename(varcache2) then verify=false elseif typename(cache)="Object" then if cache is varcache2 then verify=true else verify=false end if elseif typename(cache)="Variant()" then if join(cache,"^")=join(varcache2,"^") then verify=true else verify=false end if else if cache=varcache2 then verify=true else verify=false end if end if end function %> |