ASP Cache Class "Pioneer Cache Class" Ver2004

Source: Internet
Author: User
Tags empty join

<%
'-------------------------------------------------------------------------------------
' Please keep this declaration information when forwarding, this statement does not affect your speed!
' ************************** ' Pioneer cache class ' Ver2004 ********************************
' Author: Sun Liyu, Apollosun, Ezhonghua
' official website: http://www.lkstar.com Technical Support forum: http://bbs.lkstar.com
' e-mail: kickball@netease.com online qq:94294089
' Copyright Disclaimer: Copyright No, piracy does not investigate, the source code open, all kinds of uses can be free to use, you are welcome to the Technical forum to seek support.
' Current ASP Web sites have a growing trend, resources and speed bottlenecks
'--Using server-side caching technology can be a good solution to this contradiction, greatly accelerate the operation of ASP and improve efficiency.
' I have studied all kinds of algorithms, and it should be said that this class is the fastest and purest cache class in the present.
' Detailed use of instructions or examples please see the download attachment or to my official site download!
'--------------------------------------------------------------------------------------
class Clscache
'----------------------------
Private cache ' cached content
Private cachename ' cache application name
Private Expiretime ' cache expiration
Private expiretimename ' cache expiration application name
Private path cache page URL path

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
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.