MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / IsGood

Method IsGood

internal/utils/cachehits/stat.go:128–156  ·  view source on GitHub ↗
(category string)

Source from the content-addressed store, hash-verified

126}
127
128func (this *Stat) IsGood(category string) bool {
129 this.mu.RLock()
130 defer func() {
131 this.mu.RUnlock()
132 }()
133
134 var item = this.itemMap[category]
135 if item != nil {
136 if item.isBad {
137 return false
138 }
139 if item.isGood {
140 return true
141 }
142
143 if item.countCached > countSamples && (Tea.IsTesting() || item.timestamp < fasttime.Now().Unix()-600) /** 10 minutes ago **/ {
144 var isGood = item.countHits*100/item.countCached >= this.goodRatio
145 if isGood {
146 item.isGood = true
147 } else {
148 item.isBad = true
149 }
150
151 return isGood
152 }
153 }
154
155 return true
156}
157
158func (this *Stat) Len() int {
159 this.mu.RLock()

Callers 4

TestNewStatFunction · 0.80
BenchmarkStatFunction · 0.80
MatchStringCacheFunction · 0.80
MatchBytesCacheFunction · 0.80

Calls 4

NowFunction · 0.92
RLockMethod · 0.80
RUnlockMethod · 0.80
UnixMethod · 0.80

Tested by 2

TestNewStatFunction · 0.64
BenchmarkStatFunction · 0.64