refactor: Replace manual goroutine creation with gopool.Go

This commit is contained in:
1808837298@qq.com
2025-02-19 18:38:29 +08:00
parent 2b7435500c
commit 5937d850d9
5 changed files with 11 additions and 21 deletions

View File

@@ -2,6 +2,7 @@ package service
import (
"fmt"
"github.com/bytedance/gopkg/util/gopool"
"one-api/common"
"one-api/constant"
"strconv"
@@ -27,7 +28,7 @@ func getDuration() time.Duration {
// startCleanupTask starts a background task to clean up expired entries
func startCleanupTask() {
go func() {
gopool.Go(func() {
for {
time.Sleep(time.Hour)
now := time.Now()
@@ -40,7 +41,7 @@ func startCleanupTask() {
return true
})
}
}()
})
}
// CheckNotificationLimit checks if the user has exceeded their notification limit