feat: add vue-golang-mysql sample
Signed-off-by: fffzlfk <1319933925qq@gmail.com>
This commit is contained in:
18
vue-golang-mysql/server/cron/cron.go
Normal file
18
vue-golang-mysql/server/cron/cron.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package cron
|
||||
|
||||
import (
|
||||
"code-paste/database"
|
||||
"code-paste/model"
|
||||
"time"
|
||||
|
||||
"github.com/robfig/cron/v3"
|
||||
)
|
||||
|
||||
func Start() {
|
||||
c := cron.New()
|
||||
|
||||
c.AddFunc("@midnight", func() {
|
||||
now := time.Now().Format("2006-01-02 15:04:05")
|
||||
database.DB.Where("expired_at <= ?", now).Delete(&model.Paste{})
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user