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.Cac he.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******@newsg roup.nospam>
| From: "Lars-Erik Aabech" <la******@newsg roup.nospam>
| References: <2F************ *************** *******@microso ft.com>
| 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.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: host-81-191-131-56.bluecom.no 81.191.131.56
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP09.phx. gbl
| Xref: TK2MSFTNGXA01.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:1106 51
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| Hi!
|
| If you use the HttpContext.Cur rent.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*****@newsgr oup.nospam> wrote in message
| news:2F******** *************** ***********@mic rosoft.com...
| >I used
| > HttpContext.Cur rent.Cache["Categories "] To cache data from database.
| > The code is like that.
| >
| > public static DataView GetCategories() {
| > if ( HttpContext.Cur rent.Cache["Categories "] == null ) {
| > HttpContext.Cur rent.Cache["Categories "] = GetCategoriesFr omDB();
| > }
| > return (DataView)HttpC ontext.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?
| >
|
|
|