mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
cachevalue: simplify exported interface (#19137)
- Also add cache options type
This commit is contained in:
committed by
GitHub
parent
2bdb9511bd
commit
62ce52c8fd
@@ -354,12 +354,10 @@ type MetricsGroupOpts struct {
|
||||
|
||||
// RegisterRead register the metrics populator function to be used
|
||||
// to populate new values upon cache invalidation.
|
||||
func (g *MetricsGroup) RegisterRead(read func(ctx context.Context) []Metric) {
|
||||
g.metricsCache = cachevalue.New[[]Metric]()
|
||||
g.metricsCache.Once.Do(func() {
|
||||
g.metricsCache.ReturnLastGood = true
|
||||
g.metricsCache.TTL = g.cacheInterval
|
||||
g.metricsCache.Update = func() ([]Metric, error) {
|
||||
func (g *MetricsGroup) RegisterRead(read func(context.Context) []Metric) {
|
||||
g.metricsCache = cachevalue.NewFromFunc(g.cacheInterval,
|
||||
cachevalue.Opts{ReturnLastGood: true},
|
||||
func() ([]Metric, error) {
|
||||
if g.metricsGroupOpts.dependGlobalObjectAPI {
|
||||
objLayer := newObjectLayerFn()
|
||||
// Service not initialized yet
|
||||
@@ -418,8 +416,8 @@ func (g *MetricsGroup) RegisterRead(read func(ctx context.Context) []Metric) {
|
||||
}
|
||||
}
|
||||
return read(GlobalContext), nil
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func (m *Metric) clone() Metric {
|
||||
|
||||
Reference in New Issue
Block a user