Pioneer cache class (extremely accelerated ASP and improved execution efficiency)

Source: Internet
Author: User
Clscache public attributes
Reference content:
Valid: whether the returned value is valid. True indicates valid; false indicates invalid. Read-only.
Obtain the version information of the class. Read-only.
Value Returns the cached content. Read-only.
Name: Set the cache name and write data.
Expire sets the cache expiration time and writes data.

 
 
Clscache public Method

Reference content:
Add (cache, expiretime) value to the cache (cache content, expiration time)
Clean () Clear Cache
Verify (cache2) compares whether the cache value is the same -- Return yes or no.

 

Clscache example

Program code:
<! -- # Include file = "clscache" -->
<%
Dim content, mycache
Set mycache = new cache
Mycache. Name = "lkstar" 'defines the cache name
If mycache. Valid then 'is valid
Content = mycache. value' read cache content
Else
Content = "..." 'a large amount of content, can be a very time-consuming database query record set
Mycache. add content, dateadd ("N", 1000, now) 'value the content to the cache, and set the cache validity period to the current time + 1000 minutes
End if
Set clscache = nothing 'release the object
%>
Program code:
<%
'Timeout '-------------------------------------------------------------------------------------
'Keep this declaration information during forwarding. This declaration does not affect your speed!
************************** [Pioneer cache class] ver2004 ******* *************************
'Authors: Sun LiYu, Apollo sun, ezhonghua
'Official Site: http://www.lkstar.com technical support forum: http://bbs.lkstar.com
'Email: kickball@netease.com online QQ: 94294089
'Copyright Disclaimer: no copyright, no piracy, public source code, and free use of various purposes. You are welcome to the Technical Forum for support.
'The current ASP websites are getting bigger and bigger, and resources and speed have become bottlenecks
'-- Using the server-side cache technology can solve this conflict well, greatly accelerating ASP operation and improving efficiency.
'I have studied various algorithms with great concentration. It should be said that this class is the fastest and purest cache class currently.
'For detailed instructions or examples, please download the attachment or go to your official site to download it!
'Timeout '--------------------------------------------------------------------------------------
Class clscache
'----------------------------
Private cache 'cached content
Private cachename 'cache Application name
Private expiretime 'cache expiration time
Private expiretimename 'cache expiration time application name
Private path 'cache page URL path

Private sub class_initialize ()
Path = request. servervariables ("url ")
Path = left (path, limit Rev (path ,"/"))
End sub
 
Private sub class_terminate ()
End sub

Public property get version
Version = "Pioneer cache class version 2004"
End Property

Public property get valid' whether the read cache is valid/attribute
If isempty (cache) or (not isdate (expiretime) then
Vaild = false
Else
Valid = true
End if
End Property

Public property get value' reads the content/attribute of the current Cache
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) 'sets the cache name/attribute
Cachename = STR & Path
Cache = Application (cachename)
Expiretimename = STR & "expire" & Path
Expiretime = Application (expiretimename)
End Property

Public property let expire (TM) 'sets the cache expiration time/attribute
Expiretime = TM
Application. Lock ()
Application (expiretimename) = expiretime
Application. Unlock ()
End Property

Public sub add (varcache, varexpiretime) 'value to the cache/Method
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 () 'release Cache/Method
Application. Lock
Application (cachename) = empty
Application (expiretimename) = empty
Application. Unlock
Cache = empty
Expiretime = empty
End sub
 
Public Function verify (varcache2) 'compares whether the cache value is the same/method -- return YES or NO
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.