InsertStat 写入数据
(stat *Stat)
| 266 | |
| 267 | // InsertStat 写入数据 |
| 268 | func (this *SQLiteTask) InsertStat(stat *Stat) error { |
| 269 | if this.isStopped { |
| 270 | return nil |
| 271 | } |
| 272 | if stat == nil { |
| 273 | return nil |
| 274 | } |
| 275 | |
| 276 | this.serverIdMapLocker.Lock() |
| 277 | this.serverIdMap[stat.ServerId] = zero.New() |
| 278 | this.timeMap[stat.Time] = zero.New() |
| 279 | this.serverIdMapLocker.Unlock() |
| 280 | |
| 281 | keyData, err := json.Marshal(stat.Keys) |
| 282 | if err != nil { |
| 283 | return err |
| 284 | } |
| 285 | |
| 286 | _, err = this.insertStatStmt.Exec(stat.ServerId, stat.Hash, keyData, stat.Value, stat.Time, this.itemConfig.Version, stat.Value) |
| 287 | if err != nil { |
| 288 | return err |
| 289 | } |
| 290 | return nil |
| 291 | } |
| 292 | |
| 293 | // CleanExpired 清理数据 |
| 294 | func (this *SQLiteTask) CleanExpired() error { |