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
Navin1) 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
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Navin Mishra" wrote:
> 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
>
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
"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.nospammin.com> wrote in message
news:CA9F6ABA-FF0B-40EA-BAB2-D2077B90670C@.microsoft.com...
> 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
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
> "Navin Mishra" wrote:
> > 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
0 comments:
Post a Comment