query_range_cache.go
query_range_cache.go - Overview
This file implements a query range cache to store and retrieve time series data. It includes functionalities for finding missing time ranges in the cache, merging new data with cached data, and storing series data in the cache.
Detailed Documentation
queryCache
- Purpose: Struct representing the query cache.
- Fields:
cache
(cache.Cache
): Underlying cache implementation.fluxInterval
(time.Duration
): Duration representing the time window during which data may be incomplete.
MissInterval
- Purpose: Struct representing a missing time interval.
- Fields:
Start
(int64
): Start timestamp in milliseconds.End
(int64
): End timestamp in milliseconds.
CachedSeriesData
- Purpose: Struct representing cached series data.
- Fields:
Start
(int64
): Start timestamp in milliseconds.End
(int64
): End timestamp in milliseconds.Data
([]*v3.Series
): Time series data.
QueryCacheOption
- Purpose: Type for functional options to configure
queryCache
.
NewQueryCache
- Purpose: Creates a new
queryCache
instance. - Parameters:
opts
(...QueryCacheOption
): Functional options to configure the cache.
- Returns:
*queryCache
: A newqueryCache
instance.
WithCache
- Purpose: Functional option to set the underlying cache implementation.
- Parameters:
cache
(cache.Cache
): The cache to use.
- Returns:
QueryCacheOption
: A functional option.
WithFluxInterval
- Purpose: Functional option to set the flux interval.
- Parameters:
fluxInterval
(time.Duration
): The flux interval duration.
- Returns:
QueryCacheOption
: A functional option.
FindMissingTimeRangesV2
- Purpose: Finds the time ranges that are missing from the cache for a given query. A new implementation.
- Parameters:
start
(int64
): Start timestamp in milliseconds.end
(int64
): End timestamp in milliseconds.step
(int64
): Step in seconds.cacheKey
(string
): Cache key for the query.
- Returns:
[]MissInterval
: A slice of missing time intervals.
FindMissingTimeRanges
- Purpose: Finds the time ranges that are missing from the cache for a given query. (Older implementation)
- Parameters:
start
(int64
): Start timestamp in milliseconds.end
(int64
): End timestamp in milliseconds.step
(int64
): Step in seconds.cacheKey
(string
): Cache key for the query.
- Returns:
[]MissInterval
: A slice of missing time intervals.
getCachedSeriesData
- Purpose: Retrieves cached series data from the cache.
- Parameters:
cacheKey
(string
): Cache key for the query.
- Returns:
[]*CachedSeriesData
: A slice of cached series data.
mergeSeries
- Purpose: Merges cached series data with new series data.
- Parameters:
cachedSeries
([]*v3.Series
): Cached series data.missedSeries
([]*v3.Series
): New series data.
- Returns:
[]*v3.Series
: Merged series data.
storeMergedData
- Purpose: Stores merged data in the cache.
- Parameters:
cacheKey
(string
): Cache key for the query.mergedData
([]CachedSeriesData
): Merged data to store.
- Returns: None
MergeWithCachedSeriesDataV2
- Purpose: Merges new
CachedSeriesData
with existing data in the cache. A new implementation - Parameters:
cacheKey
(string
): Cache key.newData
([]CachedSeriesData
): New data to merge.
- Returns:
[]CachedSeriesData
: The merged data.
MergeWithCachedSeriesData
- Purpose: Merges new
CachedSeriesData
with existing data in the cache and stores the result. - Parameters:
cacheKey
(string
): Cache key.newData
([]CachedSeriesData
): New data to merge.
- Returns:
[]CachedSeriesData
: The merged data.
StoreSeriesInCache
- Purpose: Stores series data in the cache.
- Parameters:
cacheKey
(string
): Cache key.series
([]CachedSeriesData
): Series data to store.
- Returns: None
Include in Getting Started: NO