all groups > asp.net caching > april 2005 >
You're in the

asp.net caching

group:

Best location for CacheItemRemovedCallback function?


Best location for CacheItemRemovedCallback function? testtester
4/19/2005 11:28:01 PM
asp.net caching:
I'm thinking of using the CacheItemRemovedCallback, but I've never used it
before. I'm wondering where the delegate function should be located. For
something like the code below, I'm wondering where the code for
"[SomeObject].RemovedCallback" should be.

Cache.Insert ( "obj12345", Source, null, DateTime.Now.AddMinutes ( 2 ),
NoSlidingExpiration, CacheItemPriority.High, CacheItemPriorityDecay.Slow, new
CacheItemRemovedCallback ([SomeObject].RemovedCallback));

The two things that I see using for [SomeObject] could be a) "Source" in the
example above, or b) to use a static/shared function in some other class.

If the callback function is on the cached object itself, my impression is
that it would save me a cast from System.Object to access its data again (I
could ignore the System.Object parameter from the function call and use
this.(property) to work with the object instead).

Any ideas on the best practice for where this should be? (does it matter?)
Re: Best location for CacheItemRemovedCallback function? Brock Allen
4/20/2005 1:15:51 AM
It doesn't really matter where it is, I'd say. One guideline is that the
method should be static (C#) or Shared (VB.NET) so that you don't have an
extant object reference to whatever container the method is declared on.

-Brock
DevelopMentor
http://staff.develop.com/ballen



[quoted text, click to view]


Re: Best location for CacheItemRemovedCallback function? testtester
4/20/2005 12:03:03 PM
Great - many thanks.

[quoted text, click to view]
AddThis Social Bookmark Button