locked
How to register a callback for cache objects that expire it's TTL? RRS feed

  • Question

  • My scenario is a list of calling telemetry agents, pinging the server with some status. I need to adjust the control rule when devices drop but I need to know what was the device last contribution.

    How do I find all the objects that are about to expire without having to periodically vacuum the cache?

    Does TTL expiration fire a notification with the existing object (before removing it) to the callback?

    If yes what is the filter operation: Remove?

     

    Thursday, December 12, 2013 5:43 PM

All replies

  • Hi,

    May I know which type cache are you use? I didn’t familiar with the Windows Azure Cache preview, if use this cache, refer to http://msdn.microsoft.com/en-us/library/windowsazure/dn386128.aspx for more details. If any further issue, I recommend you to create a new thread in Windows Azure Cache preview forum (http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/home?forum=azurecache ) for a better help. If use In-Role Cache I suggest you read this article (http://msdn.microsoft.com/en-us/library/windowsazure/hh914130.aspx ).

    Best Regards


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, December 13, 2013 3:24 AM
  • Hi Jambor Yao,

    I am using In-Role cache, but the questions is simple:

    How to register and receive a DataCacheNotificationCallback when a cache element TTL expires. Is this possible?

    One task updates cache elements periodically, example

    Assume I have 100 elements:

    void Init()

    {

        foreach (itemin elements)

            cache.Put(elementKey, item, 30sec)

    }

    Then another function catches messages from the remote elements reporting every 10 seconds:

    void OnMessageReceived(element){

        //Update and retrigger the TTL

        cache.Put(elementKey, element, 30sec)

    }

    I want to know if one or many stop communicating.

    Friday, December 13, 2013 7:28 PM
  • Hi,

    About Receive Notifications from a Windows Azure Cache, I suggest you reading this article: http://msdn.microsoft.com/en-us/library/windowsazure/hh914156.aspx, hope this helps.

    Regards


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, December 18, 2013 8:48 AM
  • The documentation makes no description on how the duration parameter interacts with notifications.

    I tried a sandbox project.

    Created a DataCache object.

    Register a callback with filter:

    DataCacheOperations

    filter = DataCacheOperations.RemoveItem;

    The callback sends to the Output screen the notifications

    public static void OnCacheNotificationReceived(string myCacheName,
                string myRegion,
                string myKey,
                DataCacheItemVersion itemVersion,
                DataCacheOperations OperationId,
                DataCacheNotificationDescriptor nd)
            {
                //display some of the delegate parameters
                Debug.WriteLine("A cache-level notification was triggered!");
                Debug.WriteLine("    Cache: " + myCacheName);
                Debug.WriteLine("    Region: " + myRegion);
                Debug.WriteLine("    Key: " + myKey);
                Debug.WriteLine("    Operation: " + OperationId.ToString());
                Debug.WriteLine("");
            }

    Inserted 1 object using a duration of 30 seconds

    _cache.Put(key, obj, TimeSpan.FromSeconds(30));

    Then sleep 10 minutes:

    Thread.Sleep(TimeSpan.FromSeconds(600));

    The callback fired about 5 minutes after the Put method.

    Here is my config

        <dataCacheClient name="default">    
          <autoDiscover isEnabled="true" identifier="[my role]"/>
          <clientNotification pollInterval="30" maxQueueLength="10000"/>
        </dataCacheClient>
    What I did wrong?

    Friday, December 27, 2013 9:50 PM