缓存预热时不重复写入

This commit is contained in:
GoEdgeLab
2021-08-26 15:48:09 +08:00
parent 3c81750b7d
commit d65bb56051
3 changed files with 37 additions and 1 deletions
+4
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)