|
Well first off, Im not sure about the total situation.. but a wise old man once told me.. Dont optimize what doesnt need optimization.. so you may assume that lots of requests to the database takes a lot of overhead, but then again so does storing things in cache, and serialization and deserialization and hashtable lookup..
Generally, ASP.NET Cache objects are great, but Ive found that you must use them sparingly.. what seems like a great idea at first, may not end up buying you anything in terms of performance. My Cache strategy is usually to only cast LISTS of items.. not specific details records.. that way I never have to deal with optimistic caching issues, or listener events.. also because most of the time im using Oracle, which doesnt support those neat things in .NET (..yet)
So large lists of data.. like say over 500 or more rows.. I try to cache.. individual records, like RECID #42 or whatever.. I rarellllly cache.. unless its part of some funky architecture that forces me to be disconnected or limit the time I spend on a database for monetary reasons (thats happened).
That being said.. use the cache helper idea I posted on another thread..
if( HttpContext.Current.Cahce["SOME LABEL"] != null)
{
SomeObject obj = HttpContext.Current.Cache["SOME LABEL"] as SomeObject;
}
else
{
'Goto to the database to get the object instead..
}
You can use ADO.NET dataset strategies to consolidate the items you are caching, (like using mutilple DataTables and Relation objects within a single DataSet) and just cache the DataSet objects to use later. (if thats what you are using)
As far as memory goes.. Its interesting to note that ASP.NET uses 2GB memory limit for its Worker Process, including Cache... even if you dont have That much memory available.. so its worthwhile to change the Total Maximum RAM that the worker process can use.. But this is done several ways, I mean Im assuming that this is a Web Application running on IIS? If so.. which Version of IIS.. and what version of the Frameworkdo you have available.. there are several ways to configure such a thing.. and its usually wise to go in and set the Maximum memory cap to something UNDER the physical memory on your server.. (to avoid paging of course)
__________________
The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair. -Douglas Adams
|