<%
\’*********************************************************
\’紫茉莉缓存类1.0
\’ZNet CacheClass Version 1.0
\’作者:流行孤单[ZNetTech]
\’版权声明:版权所有,源代码公开,各种用途均可免费使用。
\’转发或使用时请保留此声明信息,这段声明并不会影响你的速度!
\’*********************************************************
Class CacheClass
\’声明变量
Public CacheID
Private CacheName,CacheData
\’声明类预处理内容
Private Sub Class_Initialize()
\’以过滤:/以后的路径为ID防止重复
CacheID = Replace(Server.MapPath(\”.\”),\”.\”,\”\”)
CacheID = Replace(Replace(CacheID,\”/\”,\”\”),\”:\”,\”\”)
End Sub
\’声明类终止处理内容
Private Sub Class_Terminate()
Response.Write(\”SiteCache Is End.\”)
End Sub
\’获取缓存名称
Public Property Let SetName(NameValue)
CacheName = NameValue
End Property
\’获取缓存数据
Public Property Let SetData(DataValue)
If CacheName = \”\” Then
Response.Write(\”CacheName Is Empty.\”)
Response.End
Else
ReDim CacheData(1)
CacheData(0) = DataValue
CacheData(1) = Now()
Application.Lock
Application.Contents(CacheID & \”_\” & CacheName) = CacheData
Application.UnLock
End If
End Property
\’输出缓存数据
Public Property Get GetData(NameValue)
If NameValue = \”\” Then
NameValue = CacheName
End If
If NameValue = \”\” Then
Response.Write(\”CacheName Is Empty.\”)
Response.End
Else
CacheData = Application.Contents(CacheID & \”_\” & NameValue)
If IsArray(CacheData) Then
GetData = CacheData
Else
Response.Write(\”The CacheData(\” & NameValue & \”) Is Empty.\”)
Response.End
End If
End If
End Property
\’判断对象是否过期
Public Function Overdue(NameValue)
Overdue= True
If NameValue = \”\” Then
NameValue = CacheName
End If
CacheData = Application.Contents(CacheID & \”_\” & NameValue)
If Not (IsArray(CacheData)) Then
Exit Function
End If
If Not IsDate(CacheData(1)) Then
Exit Function
End If
If DateDiff(\”s\”,CDate(CacheData(1)),Now()) < (14400 * 60) Then
Overdue = False
End If
End Function
\’删除一个缓存
Public Sub DelData(NameValue)
Application.Lock
Application.Contents.Remove(CacheID & \”_\” & NameValue)
Application.UnLock
End Sub
\’清除所有缓存
Public Sub ClsData()
Application.Lock
Application.Contents.Remove.All
Application.UnLock
End Sub
End Class
%>
- 点赞
- 收藏
- 分享
- 文章举报
景元滨_中国发布了1 篇原创文章 · 获赞 0 · 访问量 565私信关注