When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles [1.x] [2.0]
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips
Search

Sections:
Book Reviews
Sample Chapters
Commonly Asked Message Board Questions
Headlines from ASPWire.com
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
Web Hosts
XML Info
Information:
Advertise
Feedback
Author an Article
Technology Jobs

















internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers
ASP ASP.NET ASP FAQs Message Board Feedback ASP Jobs
Print this page.

Windows Systems Administrator
Jupitermedia
US-CT-Darien

Justtechjobs.com Post A Job | Post A Resume

Published: Thursday, May 20, 1999

Caching Data
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.

- continued -

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
The Application object stores data that is application wide. In other words, it stores data for that site only. Each site is considered an "application". Application can be stored in the global.asa file or you can place information in it using ASP.

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:
(I will explain it in the comments)

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


Windows Internet Technology | ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES