RunCleaner deletes every "interval" duration rows which are older than "expire" duration based on the "updated_at" field. For more info check CleanExpireRows which is used to delete old rows.
(interval, expire time.Duration)
| 91 | // "expire" duration based on the "updated_at" field. For more info check |
| 92 | // CleanExpireRows which is used to delete old rows. |
| 93 | func (p *Postgres) RunCleaner(interval, expire time.Duration) { |
| 94 | cleanFunc := func() { |
| 95 | affectedRows, err := p.CleanExpiredRows(expire) |
| 96 | if err != nil { |
| 97 | p.Log.Warning("postgres: cleaning old rows failed: %s", err) |
| 98 | } else if affectedRows != 0 { |
| 99 | p.Log.Debug("postgres: cleaned up %d rows", affectedRows) |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | for range time.Tick(interval) { |
| 104 | cleanFunc() |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | // CleanExpiredRows deletes rows that are at least "expire" duration old. So if |
| 109 | // say an expire duration of 10 second is given, it will delete all rows that |
no test coverage detected