ASP缓存类 【先锋缓存类】Ver2004

作者:孙立宇 时间:2009-01-05 12:28:00 

【先锋缓存类】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
%>
标签:缓存,类,效率,服务器,asp
0
投稿

猜你喜欢

  • 完美的js验证网址url(正则表达式)

    2008-06-07 09:36:00
  • Google投放广告的js的分析

    2008-07-15 11:34:00
  • 何在MySQL数据库中定义外键

    2009-12-17 12:29:00
  • 什么是响应式Web设计?怎样进行?

    2011-11-21 17:00:40
  • MySQL Order By索引优化

    2011-01-04 19:56:00
  • asp fckeditor自定义上传文件的文件名

    2011-03-30 11:03:00
  • CSS控制鼠标样式变换方法

    2007-11-17 07:58:00
  • mysql中普通索引和唯一索引的效率对比

    2010-12-08 16:03:00
  • ASP sql:rs.open语句详细说明

    2008-03-17 11:30:00
  • SQLServer 2008助你轻松编写T-SQL存储过程

    2010-12-06 13:38:00
  • Opera浏览器简介

    2009-02-05 20:56:00
  • 解析ASP的Application和Session对象

    2007-09-14 10:13:00
  • 各浏览器 CSS Hack 整理

    2008-01-17 10:54:00
  • 得到元素真实的背景颜色的函数

    2008-05-20 12:04:00
  • 面包屑设计

    2009-07-07 11:17:00
  • asp中记录集对象的getrows和getstring用法分析

    2012-11-30 20:09:49
  • asp开发Wap中的随笔

    2008-05-21 12:56:00
  • QQ聊天窗口链接提示效果代码

    2008-12-16 12:59:00
  • ASP连接Oracle数据库的例子

    2007-10-02 12:44:00
  • MySQL UPDATE时主键冲突引发的思考

    2008-06-21 17:00:00
  • asp之家 网络编程 m.aspxhome.com