Documentation
¶
Overview ¶
Package cache defines the inter-query cache interface that can cache data across queries
Index ¶
- func RegisterDefaultInterQueryBuiltinValueCacheConfig(name string, config *NamedValueCacheConfig)
- type Config
- type InterQueryBuiltinCacheConfig
- type InterQueryBuiltinValueCacheConfig
- type InterQueryCache
- type InterQueryCacheValue
- type InterQueryValueCache
- type InterQueryValueCacheBucket
- type NamedValueCacheConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterDefaultInterQueryBuiltinValueCacheConfig ¶ added in v1.1.0
func RegisterDefaultInterQueryBuiltinValueCacheConfig(name string, config *NamedValueCacheConfig)
RegisterDefaultInterQueryBuiltinValueCacheConfig registers a default configuration for the inter-query value cache; used when none has been explicitly configured. To disable a named cache when not configured, pass a nil config.
Types ¶
type Config ¶
type Config struct {
InterQueryBuiltinCache InterQueryBuiltinCacheConfig `json:"inter_query_builtin_cache"`
InterQueryBuiltinValueCache InterQueryBuiltinValueCacheConfig `json:"inter_query_builtin_value_cache"`
}
Config represents the configuration for the inter-query builtin cache.
func ParseCachingConfig ¶
ParseCachingConfig returns the config for the inter-query cache.
type InterQueryBuiltinCacheConfig ¶
type InterQueryBuiltinCacheConfig struct {
MaxSizeBytes *int64 `json:"max_size_bytes,omitempty"`
ForcedEvictionThresholdPercentage *int64 `json:"forced_eviction_threshold_percentage,omitempty"`
StaleEntryEvictionPeriodSeconds *int64 `json:"stale_entry_eviction_period_seconds,omitempty"`
}
InterQueryBuiltinCacheConfig represents the configuration of the inter-query cache that built-in functions can utilize. MaxSizeBytes - max capacity of cache in bytes ForcedEvictionThresholdPercentage - capacity usage in percentage after which forced FIFO eviction starts StaleEntryEvictionPeriodSeconds - time period between end of previous and start of new stale entry eviction routine
func (*InterQueryBuiltinCacheConfig) Clone ¶ added in v1.8.0
func (i *InterQueryBuiltinCacheConfig) Clone() *InterQueryBuiltinCacheConfig
Clone creates a deep copy of InterQueryBuiltinCacheConfig.
type InterQueryBuiltinValueCacheConfig ¶
type InterQueryBuiltinValueCacheConfig struct {
MaxNumEntries *int `json:"max_num_entries,omitempty"`
NamedCacheConfigs map[string]*NamedValueCacheConfig `json:"named,omitempty"`
}
InterQueryBuiltinValueCacheConfig represents the configuration of the inter-query value cache that built-in functions can utilize. MaxNumEntries - max number of cache entries
func (*InterQueryBuiltinValueCacheConfig) Clone ¶ added in v1.8.0
func (i *InterQueryBuiltinValueCacheConfig) Clone() *InterQueryBuiltinValueCacheConfig
Clone creates a deep copy of InterQueryBuiltinValueCacheConfig.
type InterQueryCache ¶
type InterQueryCache interface {
Get(key ast.Value) (value InterQueryCacheValue, found bool)
Insert(key ast.Value, value InterQueryCacheValue) int
InsertWithExpiry(key ast.Value, value InterQueryCacheValue, expiresAt time.Time) int
Delete(key ast.Value)
UpdateConfig(config *Config)
Clone(value InterQueryCacheValue) (InterQueryCacheValue, error)
}
InterQueryCache defines the interface for the inter-query cache.
func NewInterQueryCache ¶
func NewInterQueryCache(config *Config) InterQueryCache
NewInterQueryCache returns a new inter-query cache. The cache uses a FIFO eviction policy when it reaches the forced eviction threshold. Parameters:
config - to configure the InterQueryCache
func NewInterQueryCacheWithContext ¶
func NewInterQueryCacheWithContext(ctx context.Context, config *Config) InterQueryCache
NewInterQueryCacheWithContext returns a new inter-query cache with context. The cache uses a combination of FIFO eviction policy when it reaches the forced eviction threshold and a periodic cleanup routine to remove stale entries that exceed their expiration time, if specified. If configured with a zero stale_entry_eviction_period_seconds value, the stale entry cleanup routine is disabled.
Parameters:
ctx - used to control lifecycle of the stale entry cleanup routine config - to configure the InterQueryCache
type InterQueryCacheValue ¶
type InterQueryCacheValue interface {
SizeInBytes() int64
Clone() (InterQueryCacheValue, error)
}
InterQueryCacheValue defines the interface for the data that the inter-query cache holds.
type InterQueryValueCache ¶
type InterQueryValueCache interface {
InterQueryValueCacheBucket
GetCache(name string) InterQueryValueCacheBucket
UpdateConfig(config *Config)
}
func NewInterQueryValueCache ¶
func NewInterQueryValueCache(_ context.Context, config *Config) InterQueryValueCache
type InterQueryValueCacheBucket ¶ added in v1.1.0
type NamedValueCacheConfig ¶ added in v1.1.0
type NamedValueCacheConfig struct {
MaxNumEntries *int `json:"max_num_entries,omitempty"`
}
NamedValueCacheConfig represents the configuration of a named cache that built-in functions can utilize. A default configuration to be used if not explicitly configured can be registered using RegisterDefaultInterQueryBuiltinValueCacheConfig.
func (*NamedValueCacheConfig) Clone ¶ added in v1.8.0
func (n *NamedValueCacheConfig) Clone() *NamedValueCacheConfig
Clone creates a deep copy of NamedValueCacheConfig.