ASP状态封装类Cache、Cookie & Session
作者:Movoin 来源:Movoin ^ Blog 时间:2008-05-11 19:33:00
缓存是基于Application实现的
CacheState类,建议实例化时用名Cache
程序代码
<%
Class CacheState
Private IExpires
Public Default Property Get Contents(ByVal value)
Contents = values(value)
End Property
Public Property Let Expires(ByVal value)
IExpires = DateAdd("d", value, Now)
End Property
Public Property Get Expires()
Expires = IExpires
End Property
Public Sub Lock()
Application.Lock()
End Sub
Public Sub UnLock()
Application.UnLock()
End Sub
Public Sub Add(ByVal Key, ByVal value, ByVal Expire)
Expires = Expire
Lock
Application(Key) = value
Application(Key & "Expires") = Expires
UnLock
End Sub
Public Sub Remove(ByVal Key)
Lock
Application.Contents.Remove(Key)
Application.Contents.Remove(Key & "Expires")
UnLock
End Sub
Public Sub RemoveAll()
Clear()
End Sub
Public Sub Clear()
Application.Contents.RemoveAll()
End Sub
Public Function values(ByVal Key)
Dim Expire : Expire = Application(Key & "Expires")
If IsNull(Expire) or IsEmpty(Expire) Then
values = ""
Else
If IsDate(Expire) And CDate(Expire) > Now Then
values = Application(Key)
Else
Call Remove(Key)
value = ""
End If
End If
End Function
Public Function Compare(ByVal Key1, ByVal Key2)
Dim Cache1 : Cache1 = values(Key1)
Dim Cache2 : Cache2 = values(Key2)
If TypeName(Cache1) <> TypeName(Cache2) Then
Compare = True
Else
If TypeName(Cache1)="Object" Then
Compare = (Cache1 Is Cache2)
Else
If TypeName(Cache1) = "Variant()" Then
Compare = (Join(Cache1, "^") = Join(Cache2, "^"))
Else
Compare = (Cache1 = Cache2)
End If
End If
End If
End Function
Private Sub Class_initialize()
End Sub
Private Sub Class_Terminate()
End Sub
End Class
%>
标签:缓存,cache,cookie,session,asp
0
投稿
猜你喜欢
Django csrf校验的实现
2023-10-01 14:49:40
python中Flask Web 表单的使用方法介绍
2023-08-26 15:13:24
Django添加bootstrap框架时无法加载静态文件的解决方式
2023-04-16 07:27:44
python中split方法用法分析
2022-05-24 23:34:51
Perl使用Tesseract-OCR实现验证码识别教程
2022-04-22 07:52:05
Python计数器collections.Counter用法详解
2021-06-02 20:30:18
一些sql语句
2009-04-10 18:36:00
vue如何使用formData传递文件类型的数据
2024-04-30 10:33:24
python实现随机漫步方法和原理
2023-06-26 19:32:02
如何实现文本的卷屏浏览?
2010-05-24 18:36:00
17个javascript自定义函数库
2008-02-26 11:49:00
python 找出list中最大或者最小几个数的索引方法
2022-08-12 13:23:11
学习JavaScript设计模式之中介者模式
2024-04-17 10:07:57
Python的函数使用介绍
2022-07-02 12:05:42
WIn10+Anaconda环境下安装PyTorch(避坑指南)
2023-06-20 03:24:04
python处理Excel xlrd的简单使用
2023-11-29 04:13:32
200行python代码实现2048游戏
2023-02-28 16:07:21
Python自动发送和收取邮件的方法
2023-10-09 17:58:56
JS实现密码框根据焦点的获取与失去控制文字的消失与显示效果
2024-04-10 10:50:20
Python数据抓取爬虫代理防封IP方法
2022-12-18 18:32:32