467,911 Members | 1,447 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,911 developers. It's quick & easy.

About Cache

In application state, we need to use "Application.Lock()" before we write
something into Application["xxx"]. My question is do we need use
"Application.Lock()" to LOCK the cache before we write into Cache["xxx"]?
Nov 18 '05 #1
  • viewed: 1449
Share:
5 Replies
No, not required.

"eXseraph" <eX******@discussions.microsoft.com> wrote in message
news:59**********************************@microsof t.com...
In application state, we need to use "Application.Lock()" before we write
something into Application["xxx"]. My question is do we need use
"Application.Lock()" to LOCK the cache before we write into Cache["xxx"]?
Nov 18 '05 #2
someone can tell me why? How can asp.net keep synchronization without
Locking the cache?

"Shiva" wrote:
No, not required.

"eXseraph" <eX******@discussions.microsoft.com> wrote in message
news:59**********************************@microsof t.com...
In application state, we need to use "Application.Lock()" before we write
something into Application["xxx"]. My question is do we need use
"Application.Lock()" to LOCK the cache before we write into Cache["xxx"]?

Nov 18 '05 #3
Its not required. Its thread-safe.

--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"eXseraph" <eX******@discussions.microsoft.com> wrote in message
news:59**********************************@microsof t.com...
In application state, we need to use "Application.Lock()" before we write
something into Application["xxx"]. My question is do we need use
"Application.Lock()" to LOCK the cache before we write into Cache["xxx"]?

Nov 18 '05 #4
Cache is thread-safe.

"eXseraph" <eX******@discussions.microsoft.com> wrote in message
news:68**********************************@microsof t.com...
someone can tell me why? How can asp.net keep synchronization without
Locking the cache?

"Shiva" wrote:
No, not required.

"eXseraph" <eX******@discussions.microsoft.com> wrote in message
news:59**********************************@microsof t.com...
In application state, we need to use "Application.Lock()" before we write
something into Application["xxx"]. My question is do we need use
"Application.Lock()" to LOCK the cache before we write into Cache["xxx"]?

Nov 18 '05 #5
you don't strickly need it for application either, as the actually update is
thread safe. but if you use the following logic:

test if not in cache/application
build object
stick in chahe/application
else
return cache/object.

with out a lock before the test, two (or more) threads can detect the empty
state, both build the object, and both place their created objectes in the
cache (last one winning). a lock before the test will prevent the race.
-- bruce (sqlwork.com)

"eXseraph" <eX******@discussions.microsoft.com> wrote in message
news:59**********************************@microsof t.com...
| In application state, we need to use "Application.Lock()" before we write
| something into Application["xxx"]. My question is do we need use
| "Application.Lock()" to LOCK the cache before we write into Cache["xxx"]?
Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

220 posts views Thread by Brandon J. Van Every | last post: by
10 posts views Thread by Kieran Simkin | last post: by
9 posts views Thread by Joe Fallon | last post: by
4 posts views Thread by Alan Silver | last post: by
4 posts views Thread by mpaine | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.