Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
94a1aeb5
authored
Jun 19, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add data presence check before batch update in utils
parent
2cd9fd4c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
+19
-2
model/utils.go
+19
-2
No files found.
model/utils.go
View file @
94a1aeb5
...
@@ -2,11 +2,12 @@ package model
...
@@ -2,11 +2,12 @@ package model
import
(
import
(
"errors"
"errors"
"github.com/bytedance/gopkg/util/gopool"
"gorm.io/gorm"
"one-api/common"
"one-api/common"
"sync"
"sync"
"time"
"time"
"github.com/bytedance/gopkg/util/gopool"
"gorm.io/gorm"
)
)
const
(
const
(
...
@@ -48,6 +49,22 @@ func addNewRecord(type_ int, id int, value int) {
...
@@ -48,6 +49,22 @@ func addNewRecord(type_ int, id int, value int) {
}
}
func
batchUpdate
()
{
func
batchUpdate
()
{
// check if there's any data to update
hasData
:=
false
for
i
:=
0
;
i
<
BatchUpdateTypeCount
;
i
++
{
batchUpdateLocks
[
i
]
.
Lock
()
if
len
(
batchUpdateStores
[
i
])
>
0
{
hasData
=
true
batchUpdateLocks
[
i
]
.
Unlock
()
break
}
batchUpdateLocks
[
i
]
.
Unlock
()
}
if
!
hasData
{
return
}
common
.
SysLog
(
"batch update started"
)
common
.
SysLog
(
"batch update started"
)
for
i
:=
0
;
i
<
BatchUpdateTypeCount
;
i
++
{
for
i
:=
0
;
i
<
BatchUpdateTypeCount
;
i
++
{
batchUpdateLocks
[
i
]
.
Lock
()
batchUpdateLocks
[
i
]
.
Lock
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment