Newbie: Questions about Cache object

  • Thread starter Thread starter Navin Mishra
  • Start date Start date
N

Navin Mishra

Hi,

I'm trying to use Cache object for the first item. I've some questions
about that:

(1) Should Add, Remove and Insert method calls need to be synchronized ?
(2) Is it possible to add a cache dependency for cascading deletes i.e. if
cache key A is removed(based on time based expiration), so is key B which is
depnedent on it ?

Thanks in advance and regards

Navin
 
1) If you want to be absolutely threadsafe using the Cache, use the Lock
keyword in your insert etc. methods.

2) Cascading deletes from the cache should be easy to implement using the
CacheItemRemovedCallback delegate , where in the callback target for item A
you would go ahead and remove Item B.

Peter
 
Thanks for quick response. For (2), is there any example ? In callback, how
I access the Cache object as it is part og request context ? Can a key item
dependency be used instead ?

Thanks again and regards
 
Back
Top