|
Caching Serialized Recordsets :: Article - 2eNetWorX
|
|||
| 2eNetWorX :: ASP, VB, Asp.Net, Vb.Net, C#, dotNet, .Net OpenSource Projects |
| MyDev | What's New | Projects | Tutorials & Articles | Services | Stats | Contact Us |
| Guest-17023 | /dev :: home :: articles :: Caching Recorsets | 517 online visitors |
» Contributions
» Recordset Cache » OpenSource » Statisticus » OpenCYA!
» Undocumented... » Ask For Login » DSN'less Connection » Who's Online? » (All Samples)
|
Improving Database Performance by Caching serialized Recordsetsby Hakan Eskici Part 1 - Key Features and DesignPart 2 - Cache Storage and Implementation Part 3 - GetRecordset Function Part 4 - Cache Expiration and Removal Part 5 - Using the Cache Engine in your Projects Part 6 - Case Study and Final Words AbstractThis article explains how to build a Recordset caching system for your ASP web site to greatly improve the performance. Directly storing a Recordset object in an application variable is not recommended and should be avoided, because of its thread blocking issues. Therefore we will serialize the Recordset into text, then rebuild the object by deserializing it. By doing so, we can still enjoy the full Recordset object features while avoiding storing it directly in the IIS context. Introduction
If your web site features some kind of database access, then probably your ASP
pages spend most of their time during retrieving information from database tables.
Key FeaturesWe have the following key features in mind;
Design
Once we have decided the key features we would like to have, now it is time
to convert these requirements into a more formal notation.
Class DataCache 'Properties 'Connection string to connect to the database Public ConnectionString As String 'Functions (Methods with return values) 'Returns a recordset object for the SQL statement 'We use the SQL statement as the unique key Public Function GetRecordset(SQL As String) 'Methods 'Removes the cache entry for the SQL string Public Sub Remove(SQL As String) 'Removes all cache contents Public Sub RemoveAll() 'Expires (removes) cache entries that belong 'to the given Table Public Sub ExpireTable(TableName As String) End ClassSuch a class will be used in our application like:
'Declare cache and recordset objects
Dim MyCache, rs
'Create an instance of the DataCache
Set MyCache = New DataCache
'Specify the connection string
MyCache.ConnectionString = "(some connection string)"
'Get a recordset from the cache
Set rs = MyCache.GetRecordset("SELECT * FROM Customers")
'At this point, we expect to have a Recordset (rs) filled
'with records from the Customers table. The data would
'come directly from the database if this is the first
'time we get this recordset. If this is not the first
'access, then it would come from our cache, very fast!
> Next Part: Cache Storage and Implementation
|
Bot: Msn
echoPANEL, Free .NET
FogBugz Hosting Plans
|
| privacy policy , license , disclaimer , © 2000-2004, 2eNetWorX. [page generated in 656 ms.] |