About Cache

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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"]?
 
No, not required.

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"]?
 
someone can tell me why? How can asp.net keep synchronization without
Locking the cache?
 
Cache is thread-safe.

someone can tell me why? How can asp.net keep synchronization without
Locking the cache?
 
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)



| 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"]?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top