Skip to content

Commit

Permalink
Use upstream DefaultExpiration for go-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
chr4 committed Mar 14, 2021
1 parent 5805d04 commit 6ab535e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pkg/metrics/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"time"
)

const DefaultTimeout = 0

type Collector interface {
prometheus.Collector
Observe(deviceID string, collection MetricCollection)
Expand All @@ -32,7 +30,7 @@ type Metric struct {

type CacheItem struct {
DeviceID string
Metric Metric
Metric Metric
}

type MetricCollection []Metric
Expand All @@ -52,10 +50,10 @@ func NewCollector(defaultTimeout time.Duration, possibleMetrics []config.MetricC
func (c *MemoryCachedCollector) Observe(deviceID string, collection MetricCollection) {
for _, m := range collection {
item := CacheItem{
DeviceID: deviceID,
Metric: m,
DeviceID: deviceID,
Metric: m,
}
c.cache.Set(fmt.Sprintf("%s-%s", deviceID, m.Description.String()), item, DefaultTimeout)
c.cache.Set(fmt.Sprintf("%s-%s", deviceID, m.Description.String()), item, gocache.DefaultExpiration)
}
}

Expand Down

0 comments on commit 6ab535e

Please sign in to comment.