• <sub id="h4knl"><ol id="h4knl"></ol></sub>
    <sup id="h4knl"></sup>
      <sub id="h4knl"></sub>

      <sub id="h4knl"><ol id="h4knl"><em id="h4knl"></em></ol></sub><s id="h4knl"></s>
      1. <strong id="h4knl"></strong>

      2. asp緩存類代碼

        時(shí)間:2024-09-28 13:13:13 ASP 我要投稿
        • 相關(guān)推薦

        asp緩存類代碼

          至于緩存的作用,我想我也不用再多說(shuō)了,它的作用已經(jīng)很明顯,特別是對(duì)于信息量非常大或是全數(shù)據(jù)庫(kù)頁(yè)面的網(wǎng)站,他能很好地利用主機(jī)的內(nèi)存資源,加速ASP的執(zhí)行效率,減輕服務(wù)器的負(fù)擔(dān),而動(dòng)網(wǎng)在這一方面做得是最突出的,像他現(xiàn)在的dvbbs7.1.0版,更是在緩存的利用上更上一層樓,前后臺(tái)大多的操作都和緩存有關(guān),而現(xiàn)在動(dòng)網(wǎng)里用的也就是迷城浪子的緩存類,下面列出動(dòng)網(wǎng)的三大高手寫的ASP緩存類

          木鳥寫的

          復(fù)制代碼 代碼如下:

          '***

          'vbsCache類

          '

          '屬性valid,是否可用,取值前判斷

          '屬性name,cache名,新建對(duì)象后賦值

          '方法add(值,到期時(shí)間),設(shè)置cache內(nèi)容

          '屬性value,返回cache內(nèi)容

          '屬性blempty,是否未設(shè)置值

          '方法makeEmpty,釋放內(nèi)存,測(cè)試用

          '方法equal(變量1),判斷cache值是否和變量1相同

          '方法expires(time),修改過(guò)期時(shí)間為time

          '木鳥2002.12.24

          'http://www.aspsky.net/

          '***

          classCache

          privateobj'cache內(nèi)容

          privateexpireTime'過(guò)期時(shí)間

          privateexpireTimeName'過(guò)期時(shí)間application名

          privatecacheName'cache內(nèi)容application名

          privatepath'uri

          privatesubclass_initialize()

          path=request.servervariables("url")

          path=left(path,instrRev(path,"/"))

          endsub

          privatesubclass_terminate()

          endsub

          publicpropertygetblEmpty

          '是否為空

          ifisempty(obj)then

          blEmpty=true

          else

          blEmpty=false

          endif

          endproperty

          publicpropertygetvalid

          '是否可用(過(guò)期)

          ifisempty(obj)ornotisDate(expireTime)then

          valid=false

          elseifCDate(expireTime)<nowthen

          valid=false

          else

          valid=true

          endif

          endproperty

          publicpropertyletname(str)

          '設(shè)置cache名

          cacheName=str&path

          obj=application(cacheName)

          expireTimeName=str&"expires"&path

          expireTime=application(expireTimeName)

          endproperty

          publicpropertyletexpires(tm)

          '重設(shè)置過(guò)期時(shí)間

          expireTime=tm

          application.lock

          application(expireTimeName)=expireTime

          application.unlock

          endproperty

          publicsubadd(var,expire)

          '賦值

          ifisempty(var)ornotisDate(expire)then

          exitsub

          endif

          obj=var

          expireTime=expire

          application.lock

          application(cacheName)=obj

          application(expireTimeName)=expireTime

          application.unlock

          endsub

          publicpropertygetvalue

          '取值

          ifisempty(obj)ornotisDate(expireTime)then

          value=null

          elseifCDate(expireTime)<nowthen

          value=null

          else

          value=obj

          endif

          endproperty

          publicsubmakeEmpty()

          '釋放application

          application.lock

          application(cacheName)=empty

          application(expireTimeName)=empty

          application.unlock

          obj=empty

          expireTime=empty

          endsub

          publicfunctionequal(var2)

          '比較

          iftypename(obj)<>typename(var2)then

          equal=false

          elseiftypename(obj)="Object"then

          ifobjisvar2then

          equal=true

          else

          equal=false

          endif

          elseiftypename(obj)="Variant()"then

          ifjoin(obj,"^")=join(var2,"^")then

          equal=true

          else

          equal=false

          endif

          else

          ifobj=var2then

          equal=true

          else

          equal=false

          endif

          endif

          endfunction

          endclass

          木鳥類例子vbsCache類

          '

          '屬性valid,是否可用,取值前判斷

          '屬性name,cache名,新建對(duì)象后賦值

          '方法add(值,到期時(shí)間),設(shè)置cache內(nèi)容

          '屬性value,返回cache內(nèi)容

          '屬性blempty,是否未設(shè)置值

          '方法makeEmpty,釋放內(nèi)存,

          '方法DelCahe,刪除內(nèi)存

          '方法equal(變量1),判斷cache值是否和變量1相同

          '方法expires(time),修改過(guò)期時(shí)間為time

          '用法

          setmyCache=NewCache

          myCache.name="BoardJumpList"'定義緩存名

          ifmyCache.validthen'判斷是否可用(包括過(guò)期,與是否為空值)

          response.writemyCache.value'輸出

          else

          ................

          BoardJumpList=xxx

          myCache.addBoardJumpList,dateadd("n",60,now)'寫入緩存xxx.add內(nèi)容,過(guò)期時(shí)間

          response.writeBoardJumpList'輸出

          endif

          myCache.makeEmpty()釋放內(nèi)存

          mycache.DelCahe()刪除緩存

          迷城浪子寫的

          復(fù)制代碼 代碼如下:

          ClassCls_Cache

          Rem==================使用說(shuō)明====================

          Rem=本類模塊是動(dòng)網(wǎng)先鋒原創(chuàng),作者:迷城浪子。如采用本類模塊,請(qǐng)不要去掉這個(gè)說(shuō)明。這段注釋不會(huì)影響執(zhí)行的速度。

          Rem=作用:緩存和緩存管理類

          Rem=公有變量:Reloadtime過(guò)期時(shí)間(單位為分鐘)缺省值為14400

          Rem=MaxCount緩存對(duì)象的最大值,超過(guò)則自動(dòng)刪除使用次數(shù)少的對(duì)象。缺省值為300

          Rem=CacheName緩存組的總名稱,缺省值為"Dvbbs",如果一個(gè)站點(diǎn)中有超過(guò)一個(gè)緩存組,則需要外部改變這個(gè)值。

          Rem=屬性:Name定義緩存對(duì)象名稱,只寫屬性。

          Rem=屬性:value讀取和寫入緩存數(shù)據(jù)。

          Rem=函數(shù):ObjIsEmpty()判斷當(dāng)前緩存是否過(guò)期。

          Rem=方法:DelCahe(MyCaheName)手工刪除一個(gè)緩存對(duì)象,參數(shù)是緩存對(duì)象的名稱。

          Rem========================

          PublicReloadtime,MaxCount,CacheName

          PrivateLocalCacheName,CacheData,DelCount

          PrivateSubClass_Initialize()

          Reloadtime=14400

          CacheName="Dvbbs"

          EndSub

          PrivateSubSetCache(SetName,NewValue)

          Application.Lock

          Application(SetName)=NewValue

          Application.unLock

          EndSub

          PrivateSubmakeEmpty(SetName)

          Application.Lock

          Application(SetName)=Empty

          Application.unLock

          EndSub

          PublicPropertyLetName(ByValvNewValue)

          LocalCacheName=LCase(vNewValue)

          EndProperty

          PublicPropertyLetValue(ByValvNewValue)

          IfLocalCacheName<>""Then

          CacheData=Application(CacheName&"_"&LocalCacheName)

          IfIsArray(CacheData)Then

          CacheData(0)=vNewValue

          CacheData(1)=Now()

          Else

          ReDimCacheData(2)

          CacheData(0)=vNewValue

          CacheData(1)=Now()

          EndIf

          SetCacheCacheName&"_"&LocalCacheName,CacheData

          Else

          Err.RaisevbObjectError+1,"DvbbsCacheServer","pleasechangetheCacheName."

          EndIf

          EndProperty

          PublicPropertyGetValue()

          IfLocalCacheName<>""Then

          CacheData=Application(CacheName&"_"&LocalCacheName)

          IfIsArray(CacheData)Then

          Value=CacheData(0)

          Else

          Err.RaisevbObjectError+1,"DvbbsCacheServer","TheCacheDataIsEmpty."

          EndIf

          Else

          Err.RaisevbObjectError+1,"DvbbsCacheServer","pleasechangetheCacheName."

          EndIf

          EndProperty

          PublicFunctionObjIsEmpty()

          ObjIsEmpty=True

          CacheData=Application(CacheName&"_"&LocalCacheName)

          IfNotIsArray(CacheData)ThenExitFunction

          IfNotIsDate(CacheData(1))ThenExitFunction

          IfDateDiff("s",CDate(CacheData(1)),Now())<60*ReloadtimeThen

          ObjIsEmpty=False

          EndIf

          EndFunction

          PublicSubDelCahe(MyCaheName)

          makeEmpty(CacheName&"_"&MyCaheName)

          EndSub

          EndClass

          迷城浪子類例子

          SetWydCache=NewCls_Cache

          WydCache.Reloadtime=0.5'定義過(guò)期時(shí)間(以分鐘為單會(huì))

          WydCache.CacheName="pages"'定義緩存名

          IFWydCache.ObjIsEmpty()Then''判斷是否可用(包括過(guò)期,與是否為空值)

          Response.writeWydCache.Value

          Else

          ..................

          BoardJumpList=xxx

          WydCache.Value=BoardJumpList'寫入內(nèi)容

          Response.writeBoardJumpList

          Endif

          mycache.DelCahe("緩存名")刪除緩存

          slightboy寫的'========================

          復(fù)制代碼 代碼如下:

          'clsCache.asp

          '========================

          '==begin:2004-6-2621:51:47

          '==copyright:slightboy(C)1998-2004

          '==email:slightboy@msn.com

          '========================

          '========================

          'DimApplication(2)

          'Application(0)Counter計(jì)數(shù)器

          'Application(1)dateTime放置時(shí)間

          'Application(2)Content緩存內(nèi)容

          PublicPREFIX

          PublicPREFIX_LENGTH

          PrivateSubClass_Initialize()

          PREFIX="Cached:"

          PREFIX_LENGTH=7

          EndSub

          PrivateSubClass_Terminate

          EndSub

          '設(shè)置變量

          PublicPropertyLetCache(ByRefKey,ByRefContent)

          DimItem(2)

          Item(0)=0

          Item(1)=Now()

          IF(IsObject(Content))Then

          SetItem(2)=Content

          Else

          Item(2)=Content

          EndIF

          Application.Unlock

          Application(PREFIX&Key)=Item

          Application.Lock

          EndProperty

          '取出變量計(jì)數(shù)器++

          PublicPropertyGetCache(ByRefKey)

          DimItem

          Item=Application(PREFIX&Key)

          IF(IsArray(Item))Then

          IF(IsObject(Item))Then

          SetCache=Item(2)

          Else

          Cache=Item(2)

          EndIF

          Application(PREFIX&Key)(0)=Application(PREFIX&Key)(0)+1

          Else

          Cache=Empty

          EndIF

          EndProperty

          '檢查緩存對(duì)象是否存在

          PublicPropertyGetExists(ByRefKey)

          DimItem

          Item=Application(PREFIX&Key)

          IF(IsArray(Item))Then

          Exists=True

          Else

          Exists=False

          EndIF

          EndProperty

          '得到計(jì)數(shù)器數(shù)值

          PublicPropertyGetCounter(ByRefKey)

          DimItem

          Item=Application(PREFIX&Key)

          IF(IsArray(Item))Then

          Counter=Item(0)

          EndIF

          EndProperty

          '設(shè)置計(jì)數(shù)器時(shí)間

          PublicPropertyLetdateTime(ByRefKey,ByRefSetdateTime)

          DimItem

          Item=Application(PREFIX&Key)

          IF(IsArray(Item))Then

          Item(1)=SetdateTime

          EndIF

          EndProperty

          '得到計(jì)數(shù)器時(shí)間

          PublicPropertyGetdateTime(ByRefKey)

          DimItem

          Item=Application(PREFIX&Key)

          IF(IsArray(Item))Then

          dateTime=Item(1)

          EndIF

          EndProperty

          '重置計(jì)數(shù)器

          PublicSubResetCounter()

          DimKey

          DimItem

          Application.Unlock

          ForEachKeyinApplication.Contents

          IF(Left(Key,PREFIX_LENGTH)=PREFIX)Then

          Item=Application(Key)

          Item(0)=0

          Application(Key)=Item

          EndIF

          Next

          Application.Lock

          EndSub

          '刪除某以緩存

          PublicSubClear(ByRefKey)

          Application.Contents.Remove(PREFIX&Key)

          EndSub

          '清空沒(méi)有使用的緩存

          PublicSubClearUnused()

          DimKey,Keys,KeyLength,KeyIndex

          ForEachKeyinApplication.Contents

          IF(Left(Key,PREFIX_LENGTH)=PREFIX)Then

          IF(Application(Key)(0)=0)Then

          Keys=Keys&VBNewLine&Key

          EndIF

          EndIF

          Next

          Keys=Split(Keys,VBNewLine)

          KeyLength=UBound(Keys)

          Application.Unlock

          ForKeyIndex=1ToKeyLength

          Application.Contents.Remove(Keys(KeyIndex))

          Next

          Application.Lock

          EndSub

          '清空所有緩存

          PublicSubClearAll()

          DimKey,Keys,KeyLength,KeyIndex

          ForEachKeyinApplication.Contents

          IF(Left(Key,PREFIX_LENGTH)=PREFIX)Then

          Keys=Keys&VBNewLine&Key

          EndIF

          Next

          Keys=Split(Keys,VBNewLine)

          KeyLength=UBound(Keys)

          Application.Unlock

          ForKeyIndex=1ToKeyLength

          Application.Contents.Remove(Keys(KeyIndex))

          Next

          Application.Lock

          EndSub

          EndClass

          slightboyn類例子SetWyd=NewJayCache

          Wyd.dateTime("Page")=時(shí)間

          IfWyd.Exists("Page")Then

          Response.writeWyd.Cache("Page")'輸出

          Else

          Wyd.Cache("Page")=xxx寫入

          Responxe.writexxx

          EndIF

          Wyd.Clear("page")'刪除緩存

        【asp緩存類代碼】相關(guān)文章:

        防盜鏈接ASP函數(shù)實(shí)現(xiàn)代碼01-23

        ASP.NET連SQL7接口的源代碼06-06

        ASP網(wǎng)頁(yè)程序設(shè)計(jì)中10個(gè)非常有用的實(shí)例代碼08-12

        關(guān)于ASP.NET使用JavaScript顯示信息提示窗口實(shí)現(xiàn)原理及代碼05-09

        2016職稱英語(yǔ)綜合類A代碼12考試答案09-14

        硬盤的緩存容量是什么08-02

        過(guò)濾HTML代碼08-29

        網(wǎng)頁(yè)編程語(yǔ)言禁止IE緩存08-10

        主板中緩存常見(jiàn)問(wèn)題09-29

        ASP提速技巧08-05

        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码
      3. <sub id="h4knl"><ol id="h4knl"></ol></sub>
        <sup id="h4knl"></sup>
          <sub id="h4knl"></sub>

          <sub id="h4knl"><ol id="h4knl"><em id="h4knl"></em></ol></sub><s id="h4knl"></s>
          1. <strong id="h4knl"></strong>

          2. 亚洲欧美成α人在线观看 | 午夜性爱在线视频 | 中日韩国内精品视频 | 亚洲AV岛国动作片在线观看 | 亚洲一级在线播放a | 亚洲欧美久久精品一区 |