Caching settings attached to a Metric, controlling how calculated values are bucketed by time period and whether the requested date range is honoured or ignored when reading and writing the cache. Persisted to XML under the element name "cache" as a child of a metric definition, and read by QueryService when calculating a metric's value. When a durationUnit is set, QueryService snaps the metric's requested start and end dates to the boundaries of that unit (adjustToCacheStartDate and adjustToCacheEndDate) before reading or writing the cache, so metrics requested with slightly different date ranges within the same period can share a cached value. An optional MetricPrecalcConfig controls whether the metric is instead calculated ahead of time by a scheduled process.
Group: Queries
Properties
| Property | Returns | Description |
|---|---|---|
| durationUnit | TimeUnit | The time unit used to bucket cached values for this metric, such as DAYS or MONTHS. |
| ignoreDates | Boolean | Whether the metric's cache ignores the requested date range, so a single cached value is shared regardless of dates. |
| precalcConfig | MetricPrecalcConfig | The pre-calculation configuration for this metric, if it is calculated ahead of time by a scheduled process rather than on demand. |
Methods
getDurationUnit()
Returns: TimeUnit
The time unit used to bucket cached values for this metric, such as DAYS or MONTHS.
getIgnoreDates()
Returns: Boolean
Whether the metric's cache ignores the requested date range, so a single cached value is shared regardless of dates.
getPrecalcConfig()
Returns: MetricPrecalcConfig
The pre-calculation configuration for this metric, if it is calculated ahead of time by a scheduled process rather than on demand.
adjustToCacheStartDate(Date startDate)
Returns: Date
Snaps a requested start date back to the start of the cache's duration unit, so metrics requested with slightly different date ranges within the same period share one cached value. Zeroes the time of day, then moves to the first day of the year, month or week for ANNUAL, MONTHS and WEEKS; DAYS keeps the date and only loses the time of day. Returns null when ignoreDates is set, and the date unchanged when no duration unit is configured.
| Parameter | Description |
|---|---|
startDate | the requested start of the metric's date range |
adjustToCacheEndDate(Date endDate)
Returns: Date
Snaps a requested end date to the cache's duration unit boundary, the counterpart to adjustToCacheStartDate. Returns null when ignoreDates is set, and the date unchanged when no duration unit is configured. Note that this currently returns the same start-of-period boundary as adjustToCacheStartDate: the intended shift to the end of the period is calculated but not applied, because ZonedDateTime is immutable and the results are discarded.
| Parameter | Description |
|---|---|
endDate | the requested end of the metric's date range |