| 126 | } |
| 127 | |
| 128 | func (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 | |
| 158 | func (this *Stat) Len() int { |
| 159 | this.mu.RLock() |