当前位置: 网学 > 编程文档 > ASP > 正文

asp缓存类

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/17
否可用(包括过期,与是否为空值)
Response.write WydCache.Value
Else
..................
BoardJumpList=xxx
WydCache.Value=BoardJumpList '写入内容
Response.write BoardJumpList
End if

mycache.DelCahe("缓存名") 删除缓存

slightboy 写的 '========================
复制代码 代码如下:
'clsCache.asp
'========================
'== begin : 2004-6-26 21:51:47
'== copyright : slightboy (C)1998-2004
'== email : slightboy@msn.com
'========================
'========================
' Dim Application(2)
' Application(0) Counter 计数器
' Application(1) dateTime 放置时间
' Application(2) Content 缓存内容

Public PREFIX
Public PREFIX_LENGTH

Private Sub Class_Initialize()
PREFIX = "Cached:"
PREFIX_LENGTH = 7
End Sub
Private Sub Class_Terminate
End Sub
' 设置变量
Public Property Let Cache(ByRef Key, ByRef Content)
Dim Item(2)
Item(0) = 0
Item(1) = Now()
IF (IsObject(Content)) Then
Set Item(2) = Content
Else
Item(2) = Content
End IF
Application.Unlock
Application(PREFIX & Key) = Item
Application.Lock
End Property
' 取出变量 计数器++
Public Property Get Cache(ByRef Key)
Dim Item
Item = Application(PREFIX & Key)
IF (IsArray(Item)) Then
IF (IsObject(Item)) Then
Set Cache = Item(2)
Else
Cache = Item(2)
End IF
Application(PREFIX & Key)(0) = Application(PREFIX & Key)(0) + 1
Else
Cache = Empty
End IF
End Property
' 检查缓存对象是否存在
Public Property Get Exists(ByRef Key)
Dim Item
Item = Application(PREFIX & Key)
IF (IsArray(Item)) Then
Exists = True
Else
Exists = False
End IF
End Property
' 得到计数器数值
Public Property Get Counter(ByRef Key)
Dim Item
Item = Application(PREFIX & Key)
IF (IsArray(Item)) Then
Counter = Item(0)
End IF
End Property

' 设置计数器时间
Public Property Let dateTime(ByRef Key, ByRef SetdateTime)
Dim Item
Item = Application(PREFIX & Key)
IF (IsArray(Item)) Then
Item(1) = SetdateTime
End IF
End Property
' 得到计数器时间
Public Property Get dateTime(ByRef Key)
Dim Item
Item = Application(PREFIX & Key)
IF (IsArray(Item)) Then
dateTime = Item(1)
End IF
End Property

' 重置计数器
Public Sub ResetCounter()
Dim Key
Dim Item
Application.Unlock
For Each Key in Application.Contents
IF (Left(Key, PREFIX_LENGTH) = PREFIX) Then
Item = Application(Key)
Item(0) = 0
Application(Key) = Item
End IF
Next
Application.Lock
End Sub
' 删除某以缓存
Public Sub Clear(ByRef Key)
Application.Contents.Remove(PREFIX & Key)
End Sub
' 清空没有使用的缓存
Public Sub ClearUnused()
Dim Key, Keys, KeyLength, KeyIndex
For Each Key in Application.Contents
IF (Left(Key, PREFIX_LENGTH) = PREFIX) Then
IF (Application(Key)(0) = 0) Then
Keys = Keys & VBNewLine & Key
End IF
End IF
Next
Keys = Split(Keys, VBNewLine)
KeyLength = UBound(Keys)
Application.Unlock
For KeyIndex = 1 To KeyLength
Application.Contents.Remove(Keys(KeyIndex))
Next
Application.Lock
End Sub
' 清空所有缓存
Public Sub ClearAll()
Dim Key, Keys, KeyLength, KeyIndex
For Each Key in Application.Contents
IF (Left(Key, PREFIX_LENGTH) = PREFIX) Then
Keys = Keys & VBNewLine & Key
End IF
Next
Keys = Split(Keys, VBNew
  • 下一篇资讯: asp中Byval与Byref的区别
  • 网学推荐

    免费论文

    原创论文

    浏览:
    设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
    版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
    湘ICP备09003080号