feat(dashboards): add ttl based caching for datasources (#113999)

This commit is contained in:
Jean-Philippe Quéméner
2025-11-17 09:48:17 +01:00
committed by GitHub
parent 64c61c6916
commit 9dd8c85448
3 changed files with 51 additions and 22 deletions
@@ -12,6 +12,11 @@ import (
)
func RegisterConversions(s *runtime.Scheme, dsIndexProvider schemaversion.DataSourceIndexProvider) error {
// Wrap the provider once with 10s caching for all conversions.
// This prevents repeated DB queries across multiple conversion calls while allowing
// the cache to refresh periodically, making it suitable for long-lived singleton usage.
dsIndexProvider = schemaversion.WrapIndexProviderWithCache(dsIndexProvider)
// v0 conversions
if err := s.AddConversionFunc((*dashv0.Dashboard)(nil), (*dashv1.Dashboard)(nil),
withConversionMetrics(dashv0.APIVERSION, dashv1.APIVERSION, func(a, b interface{}, scope conversion.Scope) error {