()
| 206 | } |
| 207 | |
| 208 | func (this *DAUManager) Close() error { |
| 209 | this.cleanTicker.Stop() |
| 210 | |
| 211 | this.statLocker.Lock() |
| 212 | var statMap = this.statMap |
| 213 | this.statMap = map[string]int64{} |
| 214 | this.statLocker.Unlock() |
| 215 | |
| 216 | if len(statMap) == 0 { |
| 217 | return nil |
| 218 | } |
| 219 | |
| 220 | statJSON, err := json.Marshal(statMap) |
| 221 | if err != nil { |
| 222 | return err |
| 223 | } |
| 224 | |
| 225 | return os.WriteFile(this.cacheFile, statJSON, 0666) |
| 226 | } |
| 227 | |
| 228 | func (this *DAUManager) CleanStats() error { |
| 229 | if !this.isReady { |