mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-15 23:54:30 +00:00
feat: use cache to avoid database access (#158)
This commit is contained in:
@@ -36,8 +36,7 @@ func ValidateUserToken(key string) (token *Token, err error) {
|
||||
if key == "" {
|
||||
return nil, errors.New("未提供 token")
|
||||
}
|
||||
token = &Token{}
|
||||
err = DB.Where("`key` = ?", key).First(token).Error
|
||||
token, err = CacheGetTokenByKey(key)
|
||||
if err == nil {
|
||||
if token.Status != common.TokenStatusEnabled {
|
||||
return nil, errors.New("该 token 状态不可用")
|
||||
|
Reference in New Issue
Block a user