Re: Cache Issues
From: Fernando Chilvarguer (fernando_at_nospamimpex.com)
Date: 11/03/04
- Next message: briand: "How to make all pages have the same layout"
- Previous message: thomson: "ASP.net , http and socket creation"
- Next in thread: Scott Allen: "Re: Cache Issues"
- Reply: Scott Allen: "Re: Cache Issues"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 03 Nov 2004 03:32:25 GMT
Hi Steve,
Thank again for being such a great helper.
Here's the follow-up to your sugestion:
I ended up putting trace stuff everywhere and found the offending statement:
I was opening a connection to the database independent of getting the data
from the cache or from the DB.
I fixed that and now a connection is open ONLY when the data needs to be
loaded from the DB and not from the cache.
Of course, that created another question in my mind:
Why would opening a DB connection be fast sometimes and slow other times?
Shouldn't the time to open a DB connection be consistent? What am I missing?
The statement is:
SqlConnection myConnection;
string sConnString = "SERVER=" +
ConfigurationSettings.AppSettings["sServer"] .....
myConnection= new SqlConnection(sConnString);
try
{
myConnection.Open();
}
Sometimes is takes 0.002 seconds, sometimes it takes over 2 seconds.
Any ideas?
Thanks,
Fernando
"Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message
news:u58Kly1uEHA.2916@cpmsftngxa10.phx.gbl...
> Hi Fernando,
>
> Thanks a lot for your detailed response and the code snippet. I've got the
> things you've done. From the code , you're writing trace everytime when
> you
> finished retrieving data from the cache....
>
> Currently I think you can try the following things:
> 1. Since the loading time we care about is during the following sentense:
>
> object cacheItem = context.Cache[cacheItemKey];
>
> that's the code which retrieve datas from the ASP.NET's cache collection.
> So I suggest you put some code to write out the current dateTime
> string(via
> System.DateTime.Now) into trace before and after that line of code so as
> to
> see whether the period of time is about the same. Such as :
>
> if(Cache[key] != null)
> {
> Trace.Write(current time...)
> object cacheItem = context.Cache[cacheItemKey];
> Trace.Write(current time..)
>
> }
>
> 2. Also, you may add some further tracing code in where it may be in the
> execute path at runtime when we retrieve data from trace. Thus, we can
> check whether they're always going through the same execute path when we
> got different period of time(it load data from cache).
>
> Also, if you have anyother ideas, please feel free to let me know. Thanks.
>
> Regards,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>
- Next message: briand: "How to make all pages have the same layout"
- Previous message: thomson: "ASP.net , http and socket creation"
- Next in thread: Scott Allen: "Re: Cache Issues"
- Reply: Scott Allen: "Re: Cache Issues"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|