clear.go 521 B

1234567891011121314151617181920212223242526
  1. package cron
  2. import (
  3. "time"
  4. "github.com/710leo/urlooker/modules/web/g"
  5. "github.com/710leo/urlooker/modules/web/model"
  6. log "github.com/sirupsen/logrus"
  7. )
  8. func DeleteOld() {
  9. t1 := time.NewTicker(time.Duration(60) * time.Second)
  10. for {
  11. <-t1.C
  12. err := model.RelSidIpRepo.DeleteOld(int64(g.Config.KeepDurationHour))
  13. if err != nil {
  14. log.Println("delete error:", err)
  15. }
  16. err = model.ItemStatusRepo.DeleteOld(int64(g.Config.KeepDurationHour))
  17. if err != nil {
  18. log.Println("delete error:", err)
  19. }
  20. }
  21. }