blob: 12a4d24f9728c020b42203d1788e3ff33c6c678e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// SPDX-License-Identifier: GPL-3.0-or-later
package prometheus
import (
"github.com/netdata/netdata/go/plugins/plugin/go.d/agent/module"
)
func newCache() *cache {
return &cache{entries: make(map[string]*cacheEntry)}
}
type (
cache struct {
entries map[string]*cacheEntry
}
cacheEntry struct {
seen bool
notSeenTimes int
charts []*module.Chart
}
)
func (c *cache) hasP(key string) bool {
v, ok := c.entries[key]
if !ok {
v = &cacheEntry{}
c.entries[key] = v
}
v.seen = true
v.notSeenTimes = 0
return ok
}
func (c *cache) addChart(key string, chart *module.Chart) {
if v, ok := c.entries[key]; ok {
v.charts = append(v.charts, chart)
}
}
|