Search code examples
azureazure-data-explorerkqlkusto-exploreradx

Kusto Caching (Azure Data Explorer)


I am trying to understand caching in kusto. I know Azure Data Explorer gives caching OOB. However, if I set the below properties while making a call to ADX, how it behaves? I don't see any difference with and without these properties. It returns the data almost with-in the same response time. Also, assume if I make the call at 8 where the cache for that specific query will be set to 2 hours. When i call the same query at 9 using the code with same properties, will kusto ignore the cache properties because there is a cache set already or will it reset the cache to 2 hours again from 9?

clientRequestProperties.SetOption(
    ClientRequestProperties.OptionQueryResultsCacheForceRefresh,
    true
);

clientRequestProperties.SetOption(
    ClientRequestProperties.OptionQueryResultsCacheMaxAge
    2
);

Solution

    1. there are different types of cache in Kusto - the one controlled by the properties you included in your questions is the query results cache, which isn't enabled by default.

      • note that when you set ClientRequestProperties.OptionQueryResultsCacheMaxAge, you need to pass a value of type timespan, e.g. "02:00:00" (or TimeSpan.FromHours(2)) for a 2 hour period (and not 2 as you showed in your question).
      • note that when you set ClientRequestProperties.OptionQueryResultsCacheForceRefresh to true, you are forcing a cache refresh for a specific query, and cached results won't be used.
    2. the more common type referred to is the one controlled by a caching policy. This is enabled by default.