Thanks for your input Erik,
Hi Charts,
As Erik has mentioned, we are recommended to use the ASP.NET's Application
Cache through the
HttpContext.Cache.Add(.....) (or Insert method) rather than simply use the
Cache["key"] = value.....
since using the Cache["key"] will cause the added object be persisted in
the memory and won't be removed until the application restart.......
And by using the Cache.Add method, we can add expire policy for the cached
object, such as TimeSpan or FileDependency.
Here are some msdn reference which may also be helpful:
http://msdn.microsoft.com/msdnmag/is...e/default.aspx http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconcacheapis.asp
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Reply-To: "Lars-Erik Aabech" <la******@newsgroup.nospam>
| From: "Lars-Erik Aabech" <la******@newsgroup.nospam>
| References: <2F**********************************@microsoft.co m>
| Subject: Re: ASPNET cache cannot refresh
| Date: Wed, 6 Jul 2005 17:16:16 +0200
| Lines: 37
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| Message-ID: <#T**************@TK2MSFTNGP09.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: host-81-191-131-56.bluecom.no 81.191.131.56
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP09.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:110651
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi!
|
| If you use the HttpContext.Current.Cache.Add(...) method instead, you can
| specify the length of time before the cached object is reset. See the
| documentation here:
|
http://msdn.microsoft.com/library/en...webcachingcach
eclassaddtopic.asp?frame=true
|
| If you only set the item by using the indexer, you cache the item forever
or
| until the application is reset.
| You could, however, write some code in the page that updates the data,
that
| resets the cache object again. That would keep the cache syncronized at
all
| times.
|
| HTH,
| Lars-Erik
|
| "Charts" <Ac*****@newsgroup.nospam> wrote in message
| news:2F**********************************@microsof t.com...
| >I used
| > HttpContext.Current.Cache["Categories"] To cache data from database.
| > The code is like that.
| >
| > public static DataView GetCategories() {
| > if ( HttpContext.Current.Cache["Categories"] == null ) {
| > HttpContext.Current.Cache["Categories"] = GetCategoriesFromDB();
| > }
| > return (DataView)HttpContext.Current.Cache["Categories"];}
| >
| > However when database data changed, the page still keept the cached
data
| > no
| > matter how many times I refresh the page. I closed the browser, and
| > reopened
| > it, and it had no effect. Finally I restarted the machine, the data
then
| > refreshed. Is that the correct way for ASPNET cache work?
| >
|
|
|