![]() |
|
|
Published: Thursday, May 20, 1999 By Ian Stallings What is cache? Cache is data that is stored in memory as opposed to data stored on the hard drive, making it faster.
Storing data in cache makes accessing it allot easier than creating it every time someone accesses your site. For instance, say on your site there is a drop-down list that doesn't change to often and the information is pulled from a database. Instead of calling the database each and every time someone visits the site, we can cache it in memory to increase performance.
Application Object Ok, now on to the code. In this example I have a drop-down menu that the Application object as a variable. So instead of connecting to the database each time it needs to write the menu, it will pull it from this variable.
Here is the code:
<%= Application("ListBox")%>
<%
'here we define the variable'
as an a application object
ListBox = Application("ListBox")
'we then check to see if it is already set
If ListBox = "" Then
'it's not, so we go to the database and retrieve it
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "DSN=travel;UID=;PWD="
sql = "SELECT * FROM types"
Set rs = oConn.Execute(sql)
crlf = chr(13) & chr(10)
'Now we assign the recordset to the 'ListBox'
'variable using a loop
ListBox = "<select name='listbox'>" & crlf
Do Until rs.EOF
Listbox = ListBox & " <option>" & _
rs("type") & "</option>" & crlf
rs.MoveNext
Loop
'we then assign the variable to the
'Application object below
Application("ListBox") = ListBox
End If
%>
Since the data is only pulled once and then stored in memory it will be quicker. This is not neccesary with every site, but if you have a hardcore app and you want maximum performance than you might want to use it. Happy Programming!
Ian Stallings is a 26 year old Software Engineer from the Washington DC area. He has experience in Internet/Intranet development using ASP, VB, Java, SQL Server, and IIS. Prior to devoting his career to application development he worked as a systems administrator at a small ISP. When not developing applications or tinkering with computers, he masquerades as a normal human being
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||