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
ef721bb0
authored
Jun 08, 2025
by
Apple\Apple
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/main' into alpha
parents
4d9ecdb8
762d2c81
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
6 deletions
+7
-6
common/redis.go
+3
-3
model/token_cache.go
+1
-1
model/user_cache.go
+3
-2
No files found.
common/redis.go
View file @
ef721bb0
...
...
@@ -92,12 +92,12 @@ func RedisDel(key string) error {
return
RDB
.
Del
(
ctx
,
key
)
.
Err
()
}
func
Redis
HDelObj
(
key
string
)
error
{
func
Redis
DelKey
(
key
string
)
error
{
if
DebugEnabled
{
SysLog
(
fmt
.
Sprintf
(
"Redis
HDEL
: key=%s"
,
key
))
SysLog
(
fmt
.
Sprintf
(
"Redis
DEL Key
: key=%s"
,
key
))
}
ctx
:=
context
.
Background
()
return
RDB
.
H
Del
(
ctx
,
key
)
.
Err
()
return
RDB
.
Del
(
ctx
,
key
)
.
Err
()
}
func
RedisHSetObj
(
key
string
,
obj
interface
{},
expiration
time
.
Duration
)
error
{
...
...
model/token_cache.go
View file @
ef721bb0
...
...
@@ -19,7 +19,7 @@ func cacheSetToken(token Token) error {
func
cacheDeleteToken
(
key
string
)
error
{
key
=
common
.
GenerateHMAC
(
key
)
err
:=
common
.
Redis
HDelObj
(
fmt
.
Sprintf
(
"token:%s"
,
key
))
err
:=
common
.
Redis
DelKey
(
fmt
.
Sprintf
(
"token:%s"
,
key
))
if
err
!=
nil
{
return
err
}
...
...
model/user_cache.go
View file @
ef721bb0
...
...
@@ -3,11 +3,12 @@ package model
import
(
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"one-api/common"
"one-api/constant"
"time"
"github.com/gin-gonic/gin"
"github.com/bytedance/gopkg/util/gopool"
)
...
...
@@ -57,7 +58,7 @@ func invalidateUserCache(userId int) error {
if
!
common
.
RedisEnabled
{
return
nil
}
return
common
.
Redis
HDelObj
(
getUserCacheKey
(
userId
))
return
common
.
Redis
DelKey
(
getUserCacheKey
(
userId
))
}
// updateUserCache updates all user cache fields using hash
...
...
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