About Cache

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

Shiva

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

Guest

someone can tell me why? How can asp.net keep synchronization without
Locking the cache?
 
S

Shiva

Cache is thread-safe.

someone can tell me why? How can asp.net keep synchronization without
Locking the cache?
 
B

bruce barker

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

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top