locked
Search for a Criteria in cache RRS feed

  • Question

  • My task is to maintain an aggregation of many endpoint-contributions in cache, but the challenge is to subtract the value for devices that stop communication.

    There are 2 classes in the model:

        class Group
        {
            string Key { get; set; }
            long Total { get; set; }
        }
        class Machine
        {
            string Key { get; set; }
            int Contribution { get; set; }
        }

    We have a Simple Web.Api, where the endpoints post a "contribution".

    The controller invokes to the group cache "Increment" and also saves in cache the machine last contribution with a TimeToLive = 30 seconds

    The goal was to register a notification for RemoveItem and when the object duration expires, subtract the value to the Group totalizer.

    But there are 2 problems:

    • The notifications only invoke the callback every 5 minutes (can't go faster no matter what I use for TTL or the pollInterval on the cache client)
    • The callback returns the "keys" not the objects, therefore I know what object was removed but I don't know the contribution.

    Q1) MSFT experts, could you assert if registering a callback can trigger as fast as 30 seconds?

    Q2) Can Anyone suggest how to bring from cache "only the expired" records? In other words can I write a filter to query cache based on a particular attribute:

    Next a hypothetical example where I am using a TSQL query, but it can be LINQ, or anything to filter

    var machines = _cache.Get<Machine>("Select * where DateDiff(LastUpdate, Now) > 30_SEC");

     


    • Edited by Uri Kluk Tuesday, December 31, 2013 5:54 PM
    Tuesday, December 31, 2013 5:53 PM

Answers

  • Hello,

    Thanks for posting!

    Base on my experience, you could set the "pollInterval" or "ttlvalue" value in your cache node. By default, polling interval is every 300 seconds. So you may need to wait 5 minutes. I recommend you could refer to this page(http://msdn.microsoft.com/en-us/library/windowsazure/dn386128.aspx ) about Notification part . And you could refer to how to configure its value, please see this page ( http://msdn.microsoft.com/en-us/library/windowsazure/hh916611.aspx ).

    Please try it.

    Regards,

    Will


    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, January 3, 2014 6:36 AM

All replies

  • hi,

    Do you use azure cache? It seems like no related with azure.

    Wednesday, January 1, 2014 6:44 AM
  • Maybe my question is not clear.

    Yes I am using Azure Cache, and I am saying that I can't solve my problem using the cache client without having to bring down from the server the entire collection.

    Notifications for expired objects fire too slow, I am pretty sure there is a bug with RemoveItem filter because it does not respect the pollingInterval.

    And I was wondering if there is some way to Query like table storage and not only finding an element from a dictionary.

    So let me paint it plain simple:

    How to find expired objects inside the cache cluster without having to wait 5 minutes or having to bring all the dictionary back to the client and iterate it?

    Thursday, January 2, 2014 3:14 PM
  • Hello,

    Thanks for posting!

    Base on my experience, you could set the "pollInterval" or "ttlvalue" value in your cache node. By default, polling interval is every 300 seconds. So you may need to wait 5 minutes. I recommend you could refer to this page(http://msdn.microsoft.com/en-us/library/windowsazure/dn386128.aspx ) about Notification part . And you could refer to how to configure its value, please see this page ( http://msdn.microsoft.com/en-us/library/windowsazure/hh916611.aspx ).

    Please try it.

    Regards,

    Will


    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, January 3, 2014 6:36 AM