carbonapi
carbonapi copied to clipboard
Ability to set caching based on time range queried
Like graphite-web's DEFAULT_CACHE_POLICY
. This would seem to be a really useful thing for grafana integration but it's probably possible to do it better than theirs. My idea would be to set the cache to the maximum of defaultTimeoutSec
and the time resolution of each datapoint returned by the query. For example if 10 datapoints returned on a 30 minute query the cachetime would be 3m, if 168 datapoints returned for a 1 week query the cache time would be 1h. But if 1000 datapoints returned for a 3m query and defaultTimeoutSec set to 10s then the cache would be 10s.
If we did it like this, the configuration option could be something like cacheResolution
with the above algorithm being 1, if 2 then it would cache for 2* as long as the datapoint resolution, if 0.5 it would be half ie 6m and 1m30s respectively for a 10 datapoint query over a 30m time period.