| 308 | } |
| 309 | |
| 310 | func (this *SQLiteFileListDB) CleanPrefix(prefix string) error { |
| 311 | if !this.isReady { |
| 312 | return nil |
| 313 | } |
| 314 | var count = int64(10000) |
| 315 | var unixTime = fasttime.Now().Unix() // 只删除当前的,不删除新的 |
| 316 | for { |
| 317 | result, err := this.writeDB.Exec(`UPDATE "`+this.itemsTableName+`" SET expiredAt=0,staleAt=? WHERE id IN (SELECT id FROM "`+this.itemsTableName+`" WHERE expiredAt>0 AND createdAt<=? AND INSTR("key", ?)=1 LIMIT `+types.String(count)+`)`, unixTime+DefaultStaleCacheSeconds, unixTime, prefix) |
| 318 | if err != nil { |
| 319 | return this.WrapError(err) |
| 320 | } |
| 321 | affectedRows, err := result.RowsAffected() |
| 322 | if err != nil { |
| 323 | return err |
| 324 | } |
| 325 | if affectedRows < count { |
| 326 | return nil |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | func (this *SQLiteFileListDB) CleanMatchKey(key string) error { |
| 332 | if !this.isReady { |