缓存预热时不重复写入

This commit is contained in:
刘祥超
2021-08-26 15:48:09 +08:00
parent 6437875979
commit 417e10970a
3 changed files with 37 additions and 1 deletions

View File

@@ -206,6 +206,10 @@ func (this *FileList) CleanPrefix(prefix string) error {
return nil
}
defer func() {
this.memoryCache.Clean()
}()
var count = int64(10000)
for {
result, err := this.db.Exec(`UPDATE "`+this.itemsTableName+`" SET expiredAt=0 WHERE id IN (SELECT id FROM "`+this.itemsTableName+`" WHERE expiredAt>0 AND createdAt<=? AND INSTR("key", ?)=1 LIMIT `+strconv.FormatInt(count, 10)+`)`, utils.UnixTime(), prefix)