none
Are there any cache notifications for eviction?

All replies

  • Object which are evicted are considered 'deleted' and a delete notification is raised, but there is no way to differentiate between user initiated delete or eviction initiated delete operation.


    MSFT
    Tuesday, November 16, 2010 12:55 PM
  •  

    I've the same question. we need to identify item eviction for debugging purposes

    Do you mean the remove notification? I've tested it. only initiated remove raises the remove notification.

    when object is timed out the notification not raised.

    try this code:

     

                cache.AddRegionLevelCallback(IMG_PREFIX, DataCacheOperations.RemoveItem, ItemCallBack);
    Console.WriteLine("adding new item"); TimeSpan timeout = new TimeSpan(0, 0, 2); cache.Put("key2", "val2", timeout,IMG_PREFIX); Console.WriteLine("waiting..."); //cache.Remove("key2",IMG_PREFIX); \\only this line raises the remove notification Console.ReadLine(); object a = cache.Get("key2", IMG_PREFIX); Console.ReadLine();


     


    • Edited by ofiry1981 Wednesday, November 23, 2011 11:32 AM
    Wednesday, November 23, 2011 11:29 AM
  • As Gopal mentioned, notifications are raised for both the cases. However, it is important to note that the cache initiated deletes (for expiry and eviction) happen late and on a need basis.

    In your Example, if you wait for 2 secs and expect that the callback should come. It might not happen.

    For efficiency reasons, the cache initiated deletes happen in bulk and periodically. You can sleep the main thread for 5 mins and then you might be able to see the notification.

    Similarly, objects are not evicted unless the cache starts running low on memory. To simulate this you might have to put a lot of objects that do not expire in the cache.

    To answer the original question around how to find the evictions : You could look at the total no. of evictions and objects evicted counters in perfmon under AppFabric Caching. These are available at a per cache and per host level and will let you see if forced eviction happened on a cache. I am assuming you need this information for judging if the capacity planning needs to be readjusted. For automation, you could setup a SCOM alert or rule on this perfmon counter.

    • Proposed as answer by rohit_msfte Thursday, December 22, 2011 8:11 AM
    Thursday, December 22, 2011 8:11 AM