HighTechTalks DotNet Forums  

RE: HttpRuntime Cache threading

ASP.net Caching microsoft.public.dotnet.framework.aspnet.caching


Discuss RE: HttpRuntime Cache threading in the ASP.net Caching forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Joerg Jooss
 
Posts: n/a

Default RE: HttpRuntime Cache threading - 01-06-2007 , 07:50 AM






Thus wrote Erik,

Quote:
Uh... that's pretty shocking. Your sample indicates that I need to
define my own lock object. What if other libraries also use the app
cache??? They won't share my lock.

None of the articles I've seen online use locks. If this is true then
there must be a LOT of buggy web apps out there...
Agreed. Even books like Essential ASP.NET specifically metion that Cache
is thread-safe.

Comparing http://msdn.microsoft.com/library/de...classtopic.asp
and http://msdn2.microsoft.com/en-us/lib...ing.cache.aspx
makes me really wonder -- either the newer documentation is wrong or it is
one truly hideous breaking change...

Cheers,
--
Joerg Jooss
news-reply (AT) joergjooss (DOT) de




Reply With Quote
  #2  
Old   
H@2dC0d32
 
Posts: n/a

Default RE: HttpRuntime Cache threading - 01-26-2007 , 09:16 PM






The cache object you are using in ASP.NET is static.

Do you create an instance of it when you use Cache?
No!

So it is public static (shared in VB.NET), and thread safe.

No need to play wo-doo dance around thread locks with ASP.NET cache

Happy coding

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
  #3  
Old   
Joerg Jooss
 
Posts: n/a

Default RE: HttpRuntime Cache threading - 01-31-2007 , 02:18 PM



Thus wrote H (AT) 2dC0d (DOT) 32,

Quote:
The cache object you are using in ASP.NET is static.

Do you create an instance of it when you use Cache? No!

So it is public static (shared in VB.NET), and thread safe.
That's a false conclusion. All relevant Cache methods like Add(), Get(),
Insert() or its indexer are instance methods. Cache is also neither a static
meber in Page, nor in HttpContext.

Personally, I think the Windows SDK docs are simply wrong. So yes, no fiddling
with locks required ;-)

Cheers,
--
Joerg Jooss
news-reply (AT) joergjooss (DOT) de




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.