difference between application variable and cache object

Posted by Jameschowdare under Regular Expressions on 2/24/2010 | Views : 10483 | Status : [Member] | Replies : 2
here is the answer,

the application variable is not therd safe ,

but when it comes to data cache is the thread safe(i mean no need to apply the explictly the using the lock and unlock)

and it storeds in the in proces only. as per performance wise it very useful

The reference is taken from
Data Caching: The basic principle of data caching is that you add items that are expensive to create to a special built-in collection object (called Cache). This object works much like the Application object. However, a few key differences exist:

The Cache object is thread-safe: This means you don't need to explicitly lock or unlock the Cache collection before adding or removing an item. However, the objects in the Cache collection will still need to be thread-safe themselves.
Items in the cache are removed automatically: ASP.NET will remove an item if it expires, if one of the objects or files it depends on is changed, or if the server becomes low on memory. This means you can freely use the cache without worrying about wasting valuable server memory.
Items in the cache support dependencies: You can link a cached object to a file, a database table, or another type of resource. If this resource changes, your cached object is automatically deemed invalid and released.
But, as with application state, the cached object is stored in process, which means it doesn't persist if the application domain is restarted and it can't be shared between computers in a web farm.




Posted by: Sheonarayan on: 2/24/2010 [Administrator] HonoraryPlatinum

Dear Jameschowdare,

Appreciate your effort of sharing your knowledge.

Forums section is to ask question not to share knowledge. Kindly post this into the Interview section and alert the moderator to disable this post from the Forums section.

Thank you.

Sheo Narayan

Jameschowdare, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nishithraj on: 2/24/2010 [Member] Bronze

The information was useful. But as sheo's suggestion, it would be better post this interview questions.

Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

Jameschowdare, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response