forked from Ailur/burgernotes-server
Made spent cleanups run on the correct database and make them show how many rows where deleted
This commit is contained in:
parent
ef54b67803
commit
6ac1c27db5
9
main.go
9
main.go
|
@ -1440,9 +1440,16 @@ func main() {
|
|||
go func() {
|
||||
for {
|
||||
time.Sleep(time.Minute)
|
||||
_, err := conn.Exec("DELETE FROM spent WHERE expires < ?", time.Now().Unix())
|
||||
affected, err := mem.Exec("DELETE FROM spent WHERE expires < ?", time.Now().Unix())
|
||||
if err != nil {
|
||||
log.Println("[ERROR] Unknown in spent cleanup Exec():", err)
|
||||
} else {
|
||||
affectedRows, err := affected.RowsAffected()
|
||||
if err != nil {
|
||||
log.Println("[ERROR] Unknown in spent cleanup RowsAffected():", err)
|
||||
} else {
|
||||
log.Println("[INFO] Spent cleanup complete, deleted "+strconv.FormatInt(affectedRows, 10)+" rows at", time.Now().Unix())
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
Loading…
Reference in New Issue